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


PHP Logger::notify方法代码示例

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


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

示例1: sprintf

            if (isset($item['id'])) {
                $headers = Mailer::set_thread('article:' . $item['id']);
            } else {
                $headers = '';
            }
            // actual post - don't stop on error
            Mailer::notify(NULL, $to, $subject, $message, $headers);
        }
        // get the article back
        $article = Anchors::get('article:' . $_REQUEST['id']);
        // log the query submission
        if (is_object($article)) {
            $label = sprintf(i18n::c('New query: %s'), strip_tags($article->get_title()));
            $link = $context['url_to_home'] . $context['url_to_root'] . $article->get_url();
            $description = '<a href="' . $link . '">' . $link . '</a>' . "\n\n" . $article->get_teaser('basic');
            Logger::notify('query.php: ' . $label, $description);
        }
    }
    // display the form on GET
} else {
    $with_form = TRUE;
}
// display the form
if ($with_form) {
    // splash message
    $context['text'] .= '<p>' . i18n::s('Please fill out the form and it will be sent automatically to the site managers. Be as precise as possible, and mention your e-mail address to let us a chance to contact you back.') . "</p>\n";
    // the form to send a query
    $context['text'] .= '<form method="post" action="' . $context['script_url'] . '" onsubmit="return validateDocumentPost(this)" id="main_form"><div>';
    // surfer name
    if (!isset($item['edit_name'])) {
        $item['edit_name'] = Surfer::get_name();
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:query.php

示例2: sprintf

        $context['text'] .= Skin::build_block($follow_up, 'bottom');
        // log the creation of a new article
        $label = sprintf(i18n::c('Article copy: %s'), strip_tags($article->get_title()));
        // poster and target section
        if (is_object($anchor)) {
            $description = sprintf(i18n::c('Sent by %s in %s'), Surfer::get_name(), $anchor->get_title());
        } else {
            $description = sprintf(i18n::c('Sent by %s'), Surfer::get_name());
        }
        // title and link
        if ($title = $article->get_title()) {
            $description .= $title . "\n";
        }
        $description = '<a href="' . $context['url_to_home'] . $context['url_to_root'] . $article->get_url() . '">' . $article->get_title() . '</a>';
        // notify sysops
        Logger::notify('articles/duplicate.php: ' . $label, $description);
    }
    // action has to be confirmed
} elseif (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST') {
    Logger::error(i18n::s('The action has not been confirmed.'));
    // please confirm
} else {
    // the article or the anchor icon, if any
    $context['page_image'] = $item['icon_url'];
    if (!$context['page_image'] && is_object($anchor)) {
        $context['page_image'] = $anchor->get_icon_url();
    }
    // commands
    $menu = array();
    $menu[] = Skin::build_submit_button(i18n::s('Yes, I want to duplicate this page'), NULL, NULL, 'confirmed');
    if (isset($item['id'])) {
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:duplicate.php

示例3: send


//.........这里部分代码省略.........
     if (!self::$ISCONNECTED) {
         Logger::warning("ep6\\RESTClient\nClient is not connected.");
         self::errorSet("RESTC-6");
         return null;
     }
     $protocol = self::$ISSSL ? "https" : "http";
     $url = $protocol . "://" . self::$HOST . "/" . self::PATHTOREST . "/" . self::$SHOP . "/" . $command;
     $headers = array("Accept: " . self::HTTP_ACCEPT, "Content-Type: " . self::HTTP_CONTENT_TYPE_JSON, "User-Agent: " . self::USER_AGENT);
     // add authentification if there is a token
     if (InputValidator::isAuthToken(self::$AUTHTOKEN)) {
         array_push($headers, "Authorization: Bearer " . self::$AUTHTOKEN);
     }
     # parse cookies
     if (!InputValidator::isEmptyArray(self::$COOKIES)) {
         $cookiesValues = array();
         foreach (self::$COOKIES as $key => $value) {
             array_push($cookiesValues, $key . "=" . $value);
         }
         array_push($headers, "Cookie: " . implode("; ", $cookiesValues));
     }
     $curl = curl_init($url);
     curl_setopt($curl, CURLOPT_FAILONERROR, 1);
     // show full errors
     curl_setopt($curl, CURLOPT_FORBID_REUSE, 0);
     // connection can be opened
     curl_setopt($curl, CURLOPT_FRESH_CONNECT, 0);
     // no new connection required
     curl_setopt($curl, CURLOPT_NOBODY, 0);
     // show body
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
     // get response as string
     curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 0);
     // no connection timeout
     curl_setopt($curl, CURLOPT_CONNECTTIMEOUT_MS, 0);
     // no connection timeout
     curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_NONE);
     // cURL will choose the http version
     curl_setopt($curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_WHATEVER);
     // understand ipv4 and ipv6
     curl_setopt($curl, CURLINFO_HEADER_OUT, 1);
     // save the header in the log
     curl_setopt($curl, CURLOPT_HEADER, 1);
     // get the header
     if (self::$ISSSL) {
         curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
         // don't check the peer ssl cerrificate
         curl_setopt($curl, CURLOPT_PROTOCOLS, CURLPROTO_HTTPS);
         curl_setopt($curl, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTPS);
         curl_setopt($curl, CURLOPT_SSLVERSION, 0);
         // default ssl version
     } else {
         curl_setopt($curl, CURLOPT_PROTOCOLS, CURLPROTO_HTTP);
         curl_setopt($curl, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP);
     }
     switch (self::$HTTP_REQUEST_METHOD) {
         case HTTPRequestMethod::GET:
             curl_setopt($curl, CURLOPT_HTTPGET, 1);
             break;
         case HTTPRequestMethod::POST:
             $JSONpostfield = JSONHandler::createJSON($postParameter);
             curl_setopt($curl, CURLOPT_POST, 1);
             curl_setopt($curl, CURLOPT_POSTREDIR, 0);
             // don't post on redirects
             curl_setopt($curl, CURLOPT_POSTFIELDS, $JSONpostfield);
             break;
         case HTTPRequestMethod::PUT:
             $JSONpostfield = JSONHandler::createJSON($postParameter);
             array_push($headers, "Content-Length: " . strlen($JSONpostfield));
             curl_setopt($curl, CURLOPT_POSTFIELDS, $JSONpostfield);
             curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PUT');
             break;
         case HTTPRequestMethod::DELETE:
             $JSONpostfield = JSONHandler::createJSON($postParameter);
             curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE");
             curl_setopt($curl, CURLOPT_POSTFIELDS, $JSONpostfield);
             break;
         case HTTPRequestMethod::PATCH:
             $JSONpostfield = "[" . JSONHandler::createJSON($postParameter) . "]";
             curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PATCH");
             curl_setopt($curl, CURLOPT_POSTFIELDS, $JSONpostfield);
             break;
     }
     curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
     $response = curl_exec($curl);
     $info = curl_getinfo($curl);
     $error = curl_error($curl);
     curl_close($curl);
     # get header and body
     list($header, $body) = self::explodeResponse($response);
     $header = trim($header);
     $content = trim($body);
     $logMessage = "Request:\n" . "Parameters: " . http_build_query($postParameter) . "\n" . $info["request_header"] . "Response:\n" . "Size (Header/Request): " . $info["header_size"] . "/" . $info["request_size"] . " Bytes\n" . "Time (Total/Namelookup/Connect/Pretransfer/Starttransfer/Redirect): " . $info["total_time"] . " / " . $info["namelookup_time"] . " / " . $info["connect_time"] . " / " . $info["pretransfer_time"] . " / " . $info["starttransfer_time"] . " / " . $info["redirect_time"] . " seconds\n" . $response . "\n";
     Logger::notify("ep6\\RESTClient:\n" . $logMessage);
     # parse header, response code and body
     self::explodeHeader($header);
     self::$HTTP_RESPONSE_CODE = (int) $info["http_code"];
     if (!InputValidator::isEmpty($content)) {
         self::$CONTENT = $content;
     }
 }
开发者ID:dpauli,项目名称:epages-rest-php,代码行数:101,代码来源:RESTClient.class.php

示例4: send

 /**
  * This send function sends a special command to the REST server with additional parameter.
  *
  * @author David Pauli <contact@david-pauli.de>
  * @since 0.0.0
  * @since 0.0.1 Use HTTPRequestMethod enum.
  * @since 0.1.0 Allow empty message body if the status code is 204.
  * @api
  * @param String command The path which is requested in the REST client.
  * @param String[] postfields Add specific parameters to the REST server.
  * @return mixed[] The returned elements as array.
  */
 public static function send($command, $postfields = array())
 {
     if (!InputValidator::isRESTCommand($command) || !self::$ISCONNECTED || !InputValidator::isArray($postfields)) {
         return null;
     }
     $protocol = self::$ISSSL ? "https" : "http";
     $url = $protocol . "://" . self::$HOST . "/" . self::PATHTOREST . "/" . self::$SHOP . "/" . $command;
     $headers = array("Accept: " . self::HTTP_ACCEPT, "Content-Type: " . self::HTTP_CONTENT_TYPE);
     if (InputValidator::isAuthToken(self::$AUTHTOKEN)) {
         array_push($headers, "Authorization: Bearer " . self::$AUTHTOKEN);
     }
     $curl = curl_init($url);
     curl_setopt($curl, CURLOPT_FAILONERROR, 1);
     // show full errors
     curl_setopt($curl, CURLOPT_FORBID_REUSE, 0);
     // connection can be opened
     curl_setopt($curl, CURLOPT_FRESH_CONNECT, 0);
     // no new connection required
     curl_setopt($curl, CURLOPT_NOBODY, 0);
     // show body
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
     // get response as string
     curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 0);
     // no connection timeout
     curl_setopt($curl, CURLOPT_CONNECTTIMEOUT_MS, 0);
     // no connection timeout
     curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_NONE);
     // cURL will choose the http version
     curl_setopt($curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_WHATEVER);
     // understand ipv4 and ipv6
     if (self::$ISSSL) {
         curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
         // don't check the peer ssl cerrificate
         curl_setopt($curl, CURLOPT_PROTOCOLS, CURLPROTO_HTTPS);
         curl_setopt($curl, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTPS);
         curl_setopt($curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_DEFAULT);
         // default ssl version
     } else {
         curl_setopt($curl, CURLOPT_PROTOCOLS, CURLPROTO_HTTP);
         curl_setopt($curl, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP);
     }
     switch (self::$HTTP_REQUEST_METHOD) {
         case HTTPRequestMethod::GET:
             curl_setopt($curl, CURLOPT_HTTPGET, 1);
             break;
         case HTTPRequestMethod::POST:
             $JSONpostfield = JSONHandler::createJSON($postfields);
             curl_setopt($curl, CURLOPT_POST, 1);
             curl_setopt($curl, CURLOPT_POSTREDIR, 0);
             // don't post on redirects
             curl_setopt($curl, CURLOPT_POSTFIELDS, $JSONpostfield);
             break;
         case HTTPRequestMethod::PUT:
             $JSONpostfield = JSONHandler::createJSON($postfields);
             array_push($headers, "Content-Length: " . strlen($JSONpostfield));
             curl_setopt($curl, CURLOPT_POSTFIELDS, $JSONpostfield);
             curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PUT');
             break;
         case HTTPRequestMethod::DELETE:
             $JSONpostfield = JSONHandler::createJSON($postfields);
             curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE");
             curl_setopt($curl, CURLOPT_POSTFIELDS, $JSONpostfield);
             break;
         case HTTPRequestMethod::PATCH:
             $JSONpostfield = JSONHandler::createJSON($postfields);
             curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PATCH");
             curl_setopt($curl, CURLOPT_POSTFIELDS, $JSONpostfield);
             break;
     }
     curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
     $response = curl_exec($curl);
     $info = curl_getinfo($curl);
     $error = curl_error($curl);
     curl_close($curl);
     $logMessage = self::$HTTP_REQUEST_METHOD . " " . $info["url"] . "<br/>" . "<strong>Response</strong>: " . $info["http_code"] . ": <pre>" . htmlspecialchars($response) . "</pre><br/>" . "<strong>Content-Type</strong>: " . $info["content_type"] . "<br/>" . "<strong>Size</strong> (Header/Request): " . $info["header_size"] . "/" . $info["request_size"] . " Bytes<br/>" . "<strong>Time</strong> (Total/Namelookup/Connect/Pretransfer/Starttransfer/Redirect): " . $info["total_time"] . " / " . $info["namelookup_time"] . " / " . $info["connect_time"] . " / " . $info["pretransfer_time"] . " / " . $info["starttransfer_time"] . " / " . $info["redirect_time"] . " seconds<br/>";
     Logger::notify("<strong>HTTP-SEND</strong>:<br/>" . $logMessage);
     // if message body is empty this is allowed with 204
     if (!$response && $info["http_code"] != "204") {
         Logger::error("Error with send REST client: " . $error);
         return null;
     } elseif (!in_array($info["http_code"], array("200", "201", "204"))) {
         Logger::warning("Get wrong response: " . $info["http_code"]);
         return null;
     }
     return JSONHandler::parseJSON($response);
 }
开发者ID:Quaese,项目名称:ep6client-php,代码行数:98,代码来源:RESTClient.class.php

示例5: array

         $attributes['message'] = '<p>' . i18n::s('Following files have been added:') . '</p>' . $compact_list;
         $attributes['anchor'] = $anchor->get_reference();
         // notification to send by e-mail
         $mail = array();
         $mail['subject'] = sprintf(i18n::c('%s: %s'), i18n::c('Contribution'), strip_tags($anchor->get_title()));
         $mail['notification'] = Files::build_notification('multiple', $attributes);
         // one file has been added
     } elseif ($item =& Files::get_by_anchor_and_name($anchor->get_reference(), $uploaded)) {
         $context['text'] .= '<p>' . i18n::s('Following file has been added:') . '</p>' . Codes::render_object('file', $item['id']);
         // use this file record
         $_REQUEST['id'] = $item['id'];
         // log single upload
         $label = sprintf(i18n::c('New file in %s'), strip_tags($anchor->get_title()));
         $link = Files::get_permalink($item);
         $description = sprintf(i18n::c('%s at %s'), $item['file_name'], '<a href="' . $link . '">' . $link . '</a>');
         Logger::notify('files/edit.php: ' . $label, $description);
         // notification to send by e-mail
         $mail = array();
         $mail['subject'] = sprintf(i18n::c('%s: %s'), i18n::c('Contribution'), strip_tags($anchor->get_title()));
         $mail['notification'] = Files::build_notification('upload', $item);
     }
     // send to anchor watchers
     if (isset($_REQUEST['notify_watchers']) && $_REQUEST['notify_watchers'] == 'Y') {
         $anchor->alert_watchers($mail, $action, isset($_REQUEST['active']) && $_REQUEST['active'] == 'N');
     }
     // send to followers of this user
     if (isset($_REQUEST['notify_followers']) && $_REQUEST['notify_followers'] == 'Y' && Surfer::get_id() && $_REQUEST['active'] != 'N') {
         $mail['message'] = Mailer::build_notification($mail['notification'], 2);
         Users::alert_watchers('user:' . Surfer::get_id(), $mail);
     }
 }
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:edit.php

示例6: array_merge

        }
        if (is_object($anchor)) {
            $menu = array_merge($menu, array('sections/edit.php?anchor=' . urlencode($anchor->get_reference()) => i18n::s('Add another section')));
        }
        $follow_up .= Skin::build_list($menu, 'menu_bar');
        $context['text'] .= Skin::build_block($follow_up, 'bottom');
        // log the creation of a new section
        $label = sprintf(i18n::c('New section: %s'), strip_tags($section->get_title()));
        if (is_object($anchor)) {
            $description = sprintf(i18n::s('Sent by %s in %s'), Surfer::get_name(), $anchor->get_title());
        } else {
            $description = sprintf(i18n::s('Sent by %s'), Surfer::get_name());
        }
        $link = $context['url_to_home'] . $context['url_to_root'] . $section->get_url();
        $description .= "\n\n" . $section->get_teaser('basic') . "\n\n" . '<a href="' . $link . '">' . $link . '</a>';
        Logger::notify('sections/edit.php: ' . $label, $description);
    }
    // display the form on GET
} else {
    $with_form = TRUE;
}
// display the form
if ($with_form) {
    // give context
    $context['current_action'] = 'edit';
    // branch to another script to save data
    if (isset($_REQUEST['options']) && preg_match('/\\bedit_as_[a-zA-Z0-9_\\.]+?\\b/i', $_REQUEST['options'], $matches) && is_readable($matches[0] . '.php')) {
        include $matches[0] . '.php';
        return;
    } elseif (is_object($overlay) && ($deputy = $overlay->get_value('edit_as')) && is_readable('edit_as_' . $deputy . '.php')) {
        include 'edit_as_' . $deputy . '.php';
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:edit.php

示例7: finalize_update

 /**
  * do whatever is necessary when a page has been updated
  *
  * This function:
  * - logs the update
  * - sends notification to watchers and to followers
  * - "touches" the container of the page,
  * - ping referred pages remotely (via the pingback protocol)
  * - ping selected servers, if any
  * - and triggers the hook 'update'.
  *
  * The first parameter provides the watching context to consider. If call is related
  * to the creation of a published page, the context is the section that hosts the new
  * page. If call is related to a draft page that has been published, then the context
  * is the page itself.
  *
  * This function is also able to notify followers of the surfer who has initiated the
  * action.
  *
  * @param object the watching context
  * @param array attributes of the published page
  * @param object page overlay, if any
  * @param boolean TRUE if dates should be left unchanged, FALSE otherwise
  * @param boolean TRUE if watchers should be notified, FALSE otherwise
  * @param boolean TRUE if followers should be notified, FALSE otherwise
  */
 public static function finalize_update($anchor, $item, $overlay = NULL, $silently = FALSE, $with_watchers = TRUE, $with_followers = FALSE)
 {
     global $context;
     // proceed only if the page has been published
     if (isset($item['publish_date']) && $item['publish_date'] > NULL_DATE) {
         // notification to send by e-mail
         $mail = array();
         $mail['subject'] = sprintf(i18n::c('%s: %s'), i18n::c('Update'), strip_tags($item['title']));
         $mail['notification'] = Articles::build_notification('update', $item);
         $mail['headers'] = Mailer::set_thread('article:' . $item['id']);
         // allow the overlay to prevent notifications of watcherss
         if (is_object($overlay) && !$overlay->should_notify_watchers($mail)) {
             $with_watchers = FALSE;
         }
         // send to watchers of this page, and to watchers upwards
         if ($with_watchers && ($handle = new Article())) {
             $handle->load_by_content($item, $anchor);
             $handle->alert_watchers($mail, 'article:update', $item['active'] == 'N');
         }
         // never notify followers on private pages
         if (isset($item['active']) && $item['active'] == 'N') {
             $with_followers = FALSE;
         }
         // allow the overlay to prevent notifications of followers
         if (is_object($overlay) && !$overlay->should_notify_followers()) {
             $with_followers = FALSE;
         }
         // send to followers of this user
         if ($with_followers && Surfer::get_id()) {
             $mail['message'] = Mailer::build_notification($mail['notification'], 2);
             Users::alert_watchers('user:' . Surfer::get_id(), $mail);
         }
         // update anchors
         $anchor->touch('article:update', $item['id'], $silently);
         // advertise public pages
         if (isset($item['active']) && $item['active'] == 'Y') {
             // expose links within the page
             $raw = '';
             if (isset($item['introduction'])) {
                 $raw .= $item['introduction'];
             }
             if (isset($item['source'])) {
                 $raw .= ' ' . $item['source'];
             }
             if (isset($item['description'])) {
                 $raw .= ' ' . $item['description'];
             }
             // pingback to referred links, if any
             include_once $context['path_to_root'] . 'links/links.php';
             Links::ping($raw, 'article:' . $item['id']);
             // ping servers, if any
             Servers::notify($anchor->get_url());
         }
     }
     // 'update' hook
     if (is_callable(array('Hooks', 'include_scripts'))) {
         Hooks::include_scripts('update', $item['id']);
     }
     // log page update
     $label = sprintf(i18n::c('Update: %s'), strip_tags($item['title']));
     $poster = Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']);
     $description = sprintf(i18n::c('Updated by %s in %s'), $poster, $anchor->get_title());
     $description .= "\n\n" . '<a href="' . Articles::get_permalink($item) . '">' . $item['title'] . '</a>';
     Logger::notify('articles/articles.php: ' . $label, $description);
 }
开发者ID:rair,项目名称:yacs,代码行数:91,代码来源:articles.php

示例8: sendWithParameter

 /**
  * This send function sends a special command to the REST server with additional parameter.
  *
  * @param String	command		The path which is requested in the REST client.
  * @param Array		parameter	Add specific parameters to the REST server.
  * @return String	The returned JSON object or null if something is wrong.
  */
 public static function sendWithParameter($command, $parameter = array())
 {
     if (!InputValidator::isRESTCommand($command)) {
         return null;
     }
     if (!self::$ISCONNECTED) {
         return null;
     }
     $protocol = self::$ISSSL ? "https" : "http";
     $url = $protocol . "://" . self::$HOST . "/" . self::PATHTOREST . "/" . self::$SHOP . "/" . $command;
     $curl = curl_init($url);
     curl_setopt($curl, CURLOPT_FAILONERROR, 1);
     // show full errors
     curl_setopt($curl, CURLOPT_FORBID_REUSE, 0);
     // connection can be opened
     curl_setopt($curl, CURLOPT_FRESH_CONNECT, 0);
     // no new connection required
     curl_setopt($curl, CURLOPT_NOBODY, 0);
     // show body
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
     // get response as string
     curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 0);
     // no connection timeout
     curl_setopt($curl, CURLOPT_CONNECTTIMEOUT_MS, 0);
     // no connection timeout
     curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_NONE);
     // cURL will choose the http version
     curl_setopt($curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_WHATEVER);
     // understand ipv4 and ipv6
     curl_setopt($curl, CURLOPT_HTTPHEADER, array("Accept: " . self::HTTP_ACCEPT, "Authorization: Bearer " . self::$AUTHTOKEN, "Content-Type: " . self::HTTP_CONTENT_TYPE));
     if (self::$ISSSL) {
         curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
         // don't check the peer ssl cerrificate
         curl_setopt($curl, CURLOPT_PROTOCOLS, CURLPROTO_HTTPS);
         curl_setopt($curl, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTPS);
         curl_setopt($curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_DEFAULT);
         // default ssl version
     } else {
         curl_setopt($curl, CURLOPT_PROTOCOLS, CURLPROTO_HTTP);
         curl_setopt($curl, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP);
     }
     switch (self::$HTTP_REQUEST_METHOD) {
         case "GET":
             curl_setopt($curl, CURLOPT_HTTPGET, 1);
             break;
         case "POST":
             curl_setopt($curl, CURLOPT_POST, 1);
             curl_setopt($curl, CURLOPT_POSTREDIR, 0);
             // don't post on redirects
             break;
         case "PUT":
             curl_setopt($curl, CURLOPT_PUT, 1);
             break;
     }
     $response = curl_exec($curl);
     $info = curl_getinfo($curl);
     $error = curl_error($curl);
     curl_close($curl);
     $logMessage = self::$HTTP_REQUEST_METHOD . " " . $info["url"] . "<br/>" . "<strong>Response</strong>: " . $info["http_code"] . ": <pre>" . htmlspecialchars($response) . "</pre><br/>" . "<strong>Content-Type</strong>: " . $info["content_type"] . "<br/>" . "<strong>Size</strong> (Header/Request): " . $info["header_size"] . "/" . $info["request_size"] . " Bytes<br/>" . "<strong>Time</strong> (Total/Namelookup/Connect/Pretransfer/Starttransfer/Redirect): " . $info["total_time"] . " / " . $info["namelookup_time"] . " / " . $info["connect_time"] . " / " . $info["pretransfer_time"] . " / " . $info["starttransfer_time"] . " / " . $info["redirect_time"] . " seconds<br/>";
     Logger::notify("<strong>HTTP-SEND</strong>:<br/>" . $logMessage);
     if (!$response) {
         Logger::error("Error with send REST client: " . $error);
         return null;
     } elseif (!in_array($info["http_code"], array("200", "201", "204"))) {
         Logger::warning("Get wrong response: " . $info["http_code"]);
         return null;
     }
     return $response;
 }
开发者ID:jgratz,项目名称:eP6RESTclient-php,代码行数:76,代码来源:RESTClient.class.php

示例9: switch

                    $context['text'] .= Skin::build_block($follow_up, 'bottom');
                    // send silently a message to the event logger, if any
                    switch ($item['capability']) {
                        case 'A':
                            $label = sprintf(i18n::c('New associate: %s'), $item['nick_name']);
                            break;
                        case 'M':
                            $label = sprintf(i18n::c('New member: %s'), $item['nick_name']);
                            break;
                        default:
                            $label = sprintf(i18n::c('New subscriber: %s'), $item['nick_name']);
                            break;
                    }
                    $link = Users::get_permalink($item);
                    $description = '<a href="' . $link . '">' . $link . '</a>';
                    Logger::notify('users/edit.php: ' . $label, $description);
                }
            }
        }
    }
    // on GET always display the form
} else {
    $with_form = TRUE;
}
// display the form if required to do so
if ($with_form) {
    // the form to edit a user
    $context['text'] .= '<form method="post" action="' . $context['script_url'] . '" onsubmit="return validateDocumentPost(this)" id="main_form"><div>';
    $fields = array();
    // this form has several panels
    $panels = array();
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:edit.php

示例10: getProducts

 /**
  * This function returns the products by using the product filter.
  *
  * @author David Pauli <contact@david-pauli.de>
  * @return Product[] Returns an array of products.
  * @since 0.0.0
  * @since 0.1.0 Use a default Locale.
  * @since 0.1.1 Unstatic every attributes.
  * @since 0.1.2 Add error reporting.
  * @since 0.1.3 Get all results.
  * @since 0.2.0 Set error message for empty responses to notify.
  * @since 0.2.1 Implement REST client fixes.
  */
 public function getProducts()
 {
     $this->errorReset();
     $parameter = $this->getParameter();
     // if request method is blocked
     if (!RESTClient::setRequestMethod(HTTPRequestMethod::GET)) {
         $this->errorSet("RESTC-9");
         return;
     }
     RESTClient::send(self::RESTPATH . "?" . $parameter);
     $content = RESTClient::getJSONContent();
     // if respond is empty
     if (InputValidator::isEmpty($content)) {
         $this->errorSet("PF-8");
         Logger::notify("ep6\\ProductFilter\nREST respomd for getting products is empty.");
         return;
     }
     // if there is no results, page AND resultsPerPage element
     if (InputValidator::isEmptyArrayKey($content, "results") || InputValidator::isEmptyArrayKey($content, "page") || InputValidator::isEmptyArrayKey($content, "resultsPerPage")) {
         $this->errorSet("PF-9");
         Logger::error("ep6\\ProductFilter\nRespond for " . self::RESTPATH . " can not be interpreted.");
         return;
     }
     $this->results = $content['results'];
     $products = array();
     // is there any product found: load the products.
     if (!InputValidator::isEmptyArrayKey($content, "items") && sizeof($content['items']) != 0) {
         foreach ($content['items'] as $item) {
             $product = new Product($item);
             // go to every filter
             foreach ($this->filters as $filter) {
                 switch ($filter->getAttribute()) {
                     case 'stocklevel':
                         $value = array();
                         $value["stocklevel"] = $product->getStocklevel();
                         break;
                     case 'price':
                         $value = array();
                         $value["price"] = $product->getPrice()->getAmount();
                         break;
                     case 'category':
                         $value = array();
                         $value["category"] = $product->getCategories();
                         break;
                     default:
                         $value = $item;
                         break;
                 }
                 if (!InputValidator::isEmptyArrayKey($value, $filter->getAttribute()) || $filter->getOperator() == FilterOperation::UNDEF) {
                     if (!InputValidator::isArray($value[$filter->getAttribute()])) {
                         if (!$filter->isElementInFilter($value)) {
                             continue 2;
                         }
                     }
                 } else {
                     continue 2;
                 }
             }
             array_push($products, $product);
         }
     }
     return $products;
 }
开发者ID:dpauli,项目名称:epages-rest-php,代码行数:76,代码来源:ProductFilter.class.php

示例11: getOrders

 /**
  * This function returns the orders by using the order filter.
  *
  * @author David Pauli <contact@david-pauli.de>
  * @return Order[] Returns an array of orders.
  * @since 0.1.3
  * @since 0.2.0 Set error message for empty responses to notify.
  * @since 0.2.1 Implement REST client fixes.
  */
 public function getOrders()
 {
     $this->errorReset();
     $parameter = $this->getParameter();
     // if request method is blocked
     if (!RESTClient::setRequestMethod(HTTPRequestMethod::GET)) {
         $this->errorSet("RESTC-9");
         return;
     }
     RESTClient::send(self::RESTPATH . "?" . $parameter);
     $content = RESTClient::getJSONContent();
     // if respond is empty
     if (InputValidator::isEmpty($content)) {
         $this->errorSet("OF-1");
         Logger::notify("ep6\\OrderFilter\nREST respond for getting orders is empty.");
         return;
     }
     // if there is no results, page AND resultsPerPage element
     if (InputValidator::isEmptyArrayKey($content, "results") || InputValidator::isEmptyArrayKey($content, "page") || InputValidator::isEmptyArrayKey($content, "resultsPerPage")) {
         $this->errorSet("OF-2");
         Logger::error("ep6\\OrderFilter\nRespond for " . self::RESTPATH . " can not be interpreted.");
         return;
     }
     $this->results = $content['results'];
     $orders = array();
     // is there any order found: load the products.
     if (!InputValidator::isEmptyArrayKey($content, "items") && sizeof($content['items']) != 0) {
         foreach ($content['items'] as $item) {
             $order = new Order($item);
             // go to every filter
             foreach ($this->filters as $filter) {
                 if (!InputValidator::isEmptyArrayKey($item, $filter->getAttribute()) || $filter->getOperator() == FilterOperation::UNDEF) {
                     if (!InputValidator::isArray($item[$filter->getAttribute()])) {
                         if (!$filter->isElementInFilter($item)) {
                             continue 2;
                         }
                     }
                 } else {
                     continue 2;
                 }
             }
             array_push($orders, $order);
         }
     }
     return $orders;
 }
开发者ID:dpauli,项目名称:epages-rest-php,代码行数:55,代码来源:OrderFilter.class.php


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