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


PHP Logger::remember方法代码示例

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


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

示例1: elseif

    // permission denied
} elseif (!$permitted) {
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
    // deletion is confirmed
} elseif (isset($_REQUEST['confirm']) && $_REQUEST['confirm'] == 'yes') {
    // touch the related anchor before actual deletion, since the image has to be accessible at that time
    if (is_object($anchor)) {
        $anchor->touch('category:delete', $item['id']);
    }
    // attempt to delete
    if (Categories::delete($item['id'])) {
        // log item deletion
        $label = sprintf(i18n::c('Deletion: %s'), strip_tags($item['title']));
        $description = Categories::get_permalink($item);
        Logger::remember('categories/delete.php: ' . $label, $description);
        // this can appear anywhere
        Cache::clear();
        // back to the anchor page or to the index page
        if (is_object($anchor)) {
            Safe::redirect($anchor->get_url());
        } else {
            Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'categories/');
        }
    }
    // deletion has to be confirmed
} elseif (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST') {
    Logger::error(i18n::s('The action has not been confirmed.'));
} else {
    // commands
    $menu = array();
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:delete.php

示例2: decode

 /**
  * parse some news
  *
  * @param string raw data received
  * @return array a status code (TRUE is ok) and the parsing result
  */
 function decode($data)
 {
     global $context;
     // create a parser with proper character encoding
     $this->encoding = 'ISO-8859-1';
     if (preg_match('/^<\\?xml .+ encoding="utf-8".*\\?>/i', $data)) {
         $this->encoding = 'UTF-8';
     }
     $parser = xml_parser_create($this->encoding);
     // parser setup
     xml_set_object($parser, $this);
     xml_set_element_handler($parser, 'parse_start_element', 'parse_end_element');
     xml_set_character_data_handler($parser, 'parse_cdata');
     // case is meaningful
     xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, FALSE);
     // reset parsing data
     $this->current_entry = array();
     // entry currently being parsed
     $this->entries = array();
     // collection of parsed entries
     $this->feed = array();
     // hash of feed fields
     $this->textinput = array();
     $this->image = array();
     $this->elements_stack = array('atom_stream');
     $this->current_field = '';
     $this->current_name_space = false;
     // parse data
     if (!xml_parse($parser, $data)) {
         if ($context['with_debug'] == 'Y') {
             Logger::remember('services/atom_codec.php: invalid packet to decode', str_replace("\r\n", "\n", $data), 'debug');
         }
         return array(FALSE, 'Parsing error: ' . xml_error_string(xml_get_error_code($parser)) . ' at line ' . xml_get_current_line_number($parser));
     }
     xml_parser_free($parser);
     // return parsing result
     return array(TRUE, $this->entries);
 }
开发者ID:rair,项目名称:yacs,代码行数:44,代码来源:atom_codec.php

示例3: decode

 /**
  * parse a XML request according to the XML-RPC specification
  *
  * This script uses the standard XML parser included in the PHP library.
  * The objective of the decoding functions is to transform the XML tree into stemming PHP arrays.
  *
  * Following tags are used for cdata conversion
  * - &lt;base64&gt;
  * - &lt;boolean&gt;
  * - &lt;date&gt;
  * - &lt;double&gt;
  * - &lt;integer&gt;
  * - &lt;string&gt;
  *
  * Following tags are processed as leaves of the tree:
  * - &lt;/value&gt;
  * - &lt;/methodName&gt;
  *
  * Following tags are processed as nodes of the tree
  * - &lt;methodCall&gt;: push 'methodCall' (stems 'methodName' and 'params')
  * - &lt;/methodCall&gt;: pop 'methodCall'
  * - &lt;methodResponse&gt;: push 'methodResponse' (stem 'params' or 'fault')
  * - &lt;/methodResponse&gt;: pop 'methodResponse'
  * - &lt;fault&gt;: push 'fault' (stems 'faultCode' and 'faultString')
  * - &lt;/fault&gt;: pop 'fault'
  * - &lt;params&gt;: push 'params', then '-1' (list of anonymous stems)
  * - &lt;/params&gt;: pop index, then pop 'params'
  * - &lt;value&gt; under an index: increment index (works for &lt;params&gt; and for &lt;array&gt;)
  * - &lt;/name&gt;: push cdata (named stem)
  * - &lt;/member&gt;: pop cdata
  * - &lt;array&gt;: push '-1' (list of anonymous stems)
  * - &lt;/array&gt;: pop index
  *
  * @param string raw data received
  * @return array a status code (TRUE is ok) and the parsing result
  */
 function decode($data)
 {
     global $context;
     // create a parser
     $parser = xml_parser_create();
     xml_set_object($parser, $this);
     xml_set_element_handler($parser, 'parse_tag_open', 'parse_tag_close');
     xml_set_character_data_handler($parser, 'parse_cdata');
     // case is meaningful
     xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, FALSE);
     // parse data
     $this->result = array();
     $this->stack = array();
     if (!xml_parse($parser, $data)) {
         if ($context['with_debug'] == 'Y') {
             Logger::remember('services/xml_rpc_codec.php: invalid packet to decode', str_replace("\r\n", "\n", $data), 'debug');
         }
         return array(FALSE, 'Parsing error: ' . xml_error_string(xml_get_error_code($parser)) . ' at line ' . xml_get_current_line_number($parser));
     }
     xml_parser_free($parser);
     // return parsing result
     return array(TRUE, $this->result);
 }
开发者ID:rair,项目名称:yacs,代码行数:59,代码来源:xml_rpc_codec.php

示例4: unset

    $response['id'] = NULL;
} else {
    $response['id'] = $parameters['id'];
}
// do not reply if the sender has sent a notification, and if there is no error
if ($response['id'] == NULL && $response['error'] == NULL) {
    $response = '';
} else {
    // JSON-RPC 2.0 requires either some result, or an error, but not both
    if (isset($response['jsonrpc'])) {
        if ($response['error'] == NULL) {
            unset($response['error']);
        } else {
            unset($response['result']);
        }
    }
    // encode the response
    $response = Safe::json_encode($response);
    // save the response if debug mode
    if (isset($context['debug_rpc']) && $context['debug_rpc'] == 'Y') {
        Logger::remember('services/json_rpc.php: json_rpc response', $response, 'debug');
    }
}
// handle the output correctly
render_raw('application/json; charset=' . $context['charset']);
// actual transmission except on a HEAD request
if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'HEAD') {
    echo $response;
}
// the post-processing hook
finalize_page();
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:json_rpc.php

示例5: sprintf

             $content .= "\t\t" . 'case \'' . $id . '\':' . "\n" . $item . "\t\t\tbreak;\n\n";
         }
     }
     // end the serving function
     $content .= "\t\t}\n\n\t\t" . 'return $result;' . "\n";
     $content .= "\t" . '}' . "\n\n";
     // the tail section
     $content .= '}' . "\n" . '?>' . "\n";
     // compile all hooks into a single file
     if (!Safe::file_put_contents('parameters/hooks.include.php', $content)) {
         $context['text'] .= sprintf(i18n::s('Impossible to write to %s.'), 'parameters/hooks.include.php') . BR . "\n";
     } else {
         $context['text'] .= i18n::s('Hooks have been compiled in parameters/hooks.include.php') . BR . "\n";
         // remember the change
         $label = sprintf(i18n::c('%s has been updated'), 'parameters/hooks.include.php');
         Logger::remember('control/scan.php: ' . $label);
     }
     // list hooks using xml
     if (isset($xml)) {
         $xml = '<?xml version="1.0" ?>' . "\n" . '<hooks>' . "\n" . $xml . '</hooks>' . "\n";
         if (!Safe::file_put_contents('parameters/hooks.xml', $xml)) {
             $context['text'] .= sprintf(i18n::s('Impossible to write to %s.'), 'parameters/hooks.xml') . BR . "\n";
         } else {
             $context['text'] .= i18n::s('Hooks have been listed in parameters/hooks.xml') . BR . "\n";
         }
     }
 }
 // display the execution time
 $time = round(get_micro_time() - $context['start_time'], 2);
 $context['text'] .= '<p>' . sprintf(i18n::s('Script terminated in %.2f seconds.'), $time) . '</p>';
 // if the server has been switched off, update the database schema
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:scan.php

示例6: submit_page


//.........这里部分代码省略.........
     if (!isset($entry_fields['create_address'])) {
         $entry_fields['create_address'] = $user['email'];
     }
     // message edition stamp
     $entry_fields['edit_date'] = gmstrftime('%Y-%m-%d %H:%M:%S', time());
     if (!isset($entry_fields['edit_name'])) {
         $entry_fields['edit_name'] = $user['nick_name'];
     }
     if (!isset($entry_fields['edit_id'])) {
         $entry_fields['edit_id'] = $user['id'];
     }
     if (!isset($entry_fields['edit_address'])) {
         $entry_fields['edit_address'] = $user['email'];
     }
     // we have to extend an existing article --this entity is mutable
     if ($target && !strncmp($target, 'article:', 8) && ($article = Articles::get(substr($target, 8), TRUE))) {
         // append the text to article description field
         $fields = array();
         $fields['id'] = $article['id'];
         $fields['description'] = $article['description'] . $entry_fields['description'];
         $fields['silent'] = TRUE;
         Articles::put_attributes($fields);
         return $target;
         // we have to extend an existing comment --this entity is mutable
     } elseif ($target && !strncmp($target, 'comment:', 8) && ($comment = Comments::get(substr($target, 8), TRUE))) {
         // append the text to comment description field
         $comment['description'] .= $entry_fields['description'];
         Comments::post($comment);
         return $target;
         // we have to comment an existing page
     } elseif (!strncmp($anchor, 'article:', 8)) {
         // insert comment in the database
         if (!($entry_fields['id'] = Comments::post($entry_fields))) {
             Logger::remember('agents/messages.php: ' . Logger::error_pop());
             return NULL;
         }
         // debug, if required to do so
         if ($context['debug_messages'] == 'Y') {
             Logger::remember('agents/messages.php: Messages::submit_page() as a comment', $entry_fields, 'debug');
         }
         // increment the post counter of the surfer
         Users::increment_posts($user['id']);
         // clear cache
         $parent = Anchors::get($entry_fields['anchor']);
         // touch the related anchor
         if (is_object($parent) && isset($entry_fields['id'])) {
             $parent->touch('comment:create', $entry_fields['id'], TRUE);
         }
         return 'comment:' . $entry_fields['id'];
         // create a new page
     } else {
         // publish automatically, if required to do so
         $section = Anchors::get($entry_fields['anchor']);
         if (isset($context['users_with_auto_publish']) && $context['users_with_auto_publish'] == 'Y' || preg_match('/\\bauto_publish\\b/i', $options) || is_object($section) && $section->has_option('auto_publish')) {
             $entry_fields['publish_date'] = gmstrftime('%Y-%m-%d %H:%M:%S', time());
             if (!isset($entry_fields['publish_name'])) {
                 $entry_fields['publish_name'] = $user['nick_name'];
             }
             if (!isset($entry_fields['publish_id'])) {
                 $entry_fields['publish_id'] = $user['id'];
             }
             if (!isset($entry_fields['publish_address'])) {
                 $entry_fields['publish_address'] = $user['email'];
             }
         }
         // ensure we are using ids instead of nicknames
开发者ID:rair,项目名称:yacs,代码行数:67,代码来源:messages.php

示例7: header

 /**
  * change the web response
  *
  * @param string a new or updated response attribute
  * @param boolean TRUE to replace, FALSE to append
  * @param int HTTP status code to return, if any
  *
  */
 public static function header($attribute, $replace = NULL, $status = NULL)
 {
     global $context;
     // CGI and FastCGI error parsing headers
     if (substr(php_sapi_name(), 0, 3) == 'cgi') {
         $attribute = str_replace('Status:', 'HTTP/1.0', $attribute);
     }
     // in case we are validating all scripts
     if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'HEAD') {
         return;
     }
     // too late
     if (headers_sent($file, $line)) {
         // help on development machine
         if ($context['with_debug'] == 'Y') {
             Logger::remember('shared/safe.php: Can not add HTTP header', 'Headers already sent in ' . $file . ' on line ' . $line, 'debug');
         }
         // don't call header(), this would raise an error
         return;
     }
     // function has been allowed
     if (is_callable('header')) {
         if ($status) {
             header($attribute, $replace, $status);
         } elseif (is_bool($replace)) {
             header($attribute, $replace);
         } else {
             header($attribute);
         }
     }
 }
开发者ID:rair,项目名称:yacs,代码行数:39,代码来源:safe.php

示例8: addcslashes

    if (isset($_REQUEST['twilio_authentication_token'])) {
        $content .= '$context[\'twilio_authentication_token\']=\'' . addcslashes($_REQUEST['twilio_authentication_token'], "\\'") . "';\n";
    }
    $content .= '?>' . "\n";
    // update the parameters file
    if (!Safe::file_put_contents('parameters/services.include.php', $content)) {
        Logger::error(sprintf(i18n::s('ERROR: Impossible to write to the file %s. The configuration has not been saved.'), 'parameters/services.include.php'));
        // allow for a manual update
        $context['text'] .= '<p style="text-decoration: blink;">' . sprintf(i18n::s('To actually change the configuration, please copy and paste following lines by yourself in file %s.'), 'parameters/services.include.php') . "</p>\n";
        // job done
    } else {
        $context['text'] .= '<p>' . sprintf(i18n::s('The following configuration has been saved into the file %s.'), 'parameters/services.include.php') . "</p>\n";
        // purge the cache
        Cache::clear();
        // remember the change
        $label = sprintf(i18n::c('%s has been updated'), 'parameters/services.include.php');
        Logger::remember('services/configure.php: ' . $label);
    }
    // display updated parameters
    $context['text'] .= Skin::build_box(i18n::s('Configuration parameters'), Safe::highlight_string($content), 'folded');
    // follow-up commands
    $follow_up = i18n::s('Where do you want to go now?');
    $menu = array();
    $menu = array_merge($menu, array('services/' => i18n::s('Web services')));
    $menu = array_merge($menu, array('control/' => i18n::s('Control Panel')));
    $menu = array_merge($menu, array('services/configure.php' => i18n::s('Configure again')));
    $follow_up .= Skin::build_list($menu, 'menu_bar');
    $context['text'] .= Skin::build_block($follow_up, 'bottom');
}
// render the skin
render_skin();
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:configure.php

示例9: sprintf

        $count++;
        // avoid timeouts
        if (!($count % 50)) {
            Safe::set_time_limit(30);
            SQL::ping();
        }
    }
    if ($count) {
        $context['text'] .= sprintf(i18n::s('%d files have been updated.'), $count) . "\n";
    }
    $context['text'] .= "</p>\n";
    // display the execution time
    $time = round(get_micro_time() - $context['start_time'], 2);
    $context['text'] .= '<p>' . sprintf(i18n::s('Script terminated in %.2f seconds.'), $time) . '</p>';
    // forward to the index page
    $menu = array('control/' => i18n::s('Control Panel'));
    $context['text'] .= Skin::build_list($menu, 'menu_bar');
    // remember the operation
    $label = sprintf(i18n::c('chmod %s has been applied to scripts'), $context['file_mask']);
    Logger::remember('control/chmod.php: ' . $label);
    // confirmation is required
} else {
    // the confirmation question
    $context['text'] .= '<b>' . sprintf(i18n::s('You are about to chmod(%d) all running scripts of this server. Are you sure?'), $context['file_mask']) . "</b>\n";
    // the menu for this page
    $context['text'] .= '<form method="post" action="' . $context['script_url'] . '"><p>' . Skin::build_submit_button(i18n::s('Yes, I do want to change permissions of running scripts')) . '<input type="hidden" name="action" value="confirm" />' . '</p></form>' . "\n";
    // this may take several minutes
    $context['text'] .= '<p>' . i18n::s('When you will click on the button the server will be immediately requested to proceed. However, because of the so many things to do on the back-end, you may have to wait for minutes before getting a response displayed. Thank you for your patience.') . "</p>\n";
}
// render the skin
render_skin();
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:chmod.php

示例10: array

    $menu = array();
    $menu[] = Skin::build_link($anchor->get_url('files'), i18n::s('Done'), 'button');
    $menu[] = Skin::build_link(Files::get_url($item['id'], 'release'), i18n::s('Release reservation'), 'span');
    $context['text'] .= Skin::build_block(Skin::finalize_list($menu, 'menu_bar'), 'bottom');
    // deletion is confirmed
} elseif (isset($_REQUEST['confirm']) && $_REQUEST['confirm'] == 'yes') {
    // touch the related anchor before actual deletion, since the file has to be accessible at that time
    if (is_object($anchor)) {
        $anchor->touch('file:delete', $item['id']);
    }
    // if no error, back to the anchor or to the index page
    if (Files::delete($item['id'])) {
        // log item deletion
        $label = sprintf(i18n::c('Deletion: %s'), strip_tags($item['title']));
        $description = Files::get_permalink($item);
        Logger::remember('files/delete.php: ' . $label, $description);
        Files::clear($item);
        if ($render_overlaid) {
            echo 'delete done';
            die;
        }
        if (is_object($anchor)) {
            Safe::redirect($anchor->get_url() . '#_attachments');
        } else {
            Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'files/');
        }
    }
    // deletion has to be confirmed
} elseif (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST') {
    Logger::error(i18n::s('The action has not been confirmed.'));
} else {
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:delete.php

示例11: list

            list($server_ping, $server_label) = $attributes;
            $milestone = get_micro_time();
            $result = @Call::invoke($server_ping, 'weblogUpdates.ping', array(strip_tags($context['site_name']), $context['url_to_home'] . $context['url_to_root']), 'XML-RPC');
            if ($result[0]) {
                $label = round(get_micro_time() - $milestone, 2) . ' sec.';
            } else {
                $label = @$result[1];
            }
            $context['text'] .= '<li>' . $server_label . ' (' . $label . ')</li>';
        }
        $context['text'] .= '</ul>';
        // no server to ping
    } else {
        $context['text'] .= '<p>' . i18n::s('No server has been created yet.') . '</p>';
    }
    // back to the index of servers
    $menu = array('servers/' => i18n::s('Servers'));
    $context['text'] .= Skin::build_list($menu, 'menu_bar');
    // remember this in log as well
    Logger::remember('servers/ping.php: The cloud has been pinged');
    // operation has to be confirmed
} else {
    // introductory text
    $context['text'] .= '<p>' . i18n::s('This script will ping (<code>weblogUpdates.ping</code>) every server configured to be part of our cloud. Normally, the publication script does this automatically. However, no ping occurs for pages submitted by XML-RPC or by e-mail. Therefore, you should launch this script at least once per month to ensure everybody knows about this site.') . '</p>';
    // the submit button
    $context['text'] .= '<form method="post" action="' . $context['script_url'] . '" id="main_form"><p>' . '<input type="hidden" name="action" value="ping" />' . Skin::build_submit_button(i18n::s('Yes, I want to ping the cloud')) . '</p></form>';
    // set the focus on the backup button
    Page::insert_script('$("#go").focus();');
}
// render the skin
render_skin();
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:ping.php

示例12: send_body

/**
 * dynamically generate the page
 *
 * @see skins/index.php
 */
function send_body()
{
    global $context, $local;
    // $local is required to localize included scripts
    // include every script that has to be run once
    global $scripts, $scripts_count;
    if (@count($scripts)) {
        // the alphabetical order may be used to control script execution order
        sort($scripts);
        reset($scripts);
        // process each script one by one
        foreach ($scripts as $item) {
            // do not execute on first installation
            if (file_exists('../parameters/switch.on') || file_exists('../parameters/switch.off')) {
                // ensure we have a valid database resource
                if (!$context['connection']) {
                    break;
                }
                // remember this as an event
                Logger::remember('scripts/run_once.php: ' . sprintf(i18n::c('script %s has been executed'), $item));
                // where scripts actually are
                $actual_item = str_replace('//', '/', $context['path_to_root'] . 'scripts/run_once/' . $item);
                // include the script to execute it
                $scripts_count++;
                echo Skin::build_block($item, 'subtitle');
                include $actual_item;
                echo "\n";
            }
            // ensure enough overall execution time
            Safe::set_time_limit(30);
            // stamp the file to remember execution time
            Safe::touch($actual_item);
            // rename the script to avoid further execution
            Safe::unlink($actual_item . '.done');
            Safe::rename($actual_item, $actual_item . '.done');
        }
        // refresh javascript libraries
        Cache::purge('js');
    }
    // report on actual execution
    if ($scripts_count) {
        echo '<p>&nbsp;</p><p>' . sprintf(i18n::ns('%d script has been executed', '%d scripts have been executed', $scripts_count), $scripts_count) . "</p>\n";
    } else {
        echo '<p>' . i18n::s('No script has been executed') . "</p>\n";
    }
    // display the total execution time
    $time = round(get_micro_time() - $context['start_time'], 2);
    if ($time > 30) {
        echo '<p>' . sprintf(i18n::s('Script terminated in %.2f seconds.'), $time) . '</p>';
    }
    // if the server has been switched off, go back to the control panel
    if (file_exists('../parameters/switch.off')) {
        echo '<form method="get" action="' . $context['url_to_root'] . 'control/">' . "\n" . '<p class="assistant_bar">' . Skin::build_submit_button(i18n::s('Control Panel')) . '</p>' . "\n" . '</form>' . "\n";
        // else back to the control panel as well, but without a button
    } else {
        $menu = array('control/' => i18n::s('Control Panel'));
        echo Skin::build_list($menu, 'menu_bar');
    }
    // purge the cache, since it is likely that we have modified some data
    Cache::clear();
}
开发者ID:rair,项目名称:yacs,代码行数:66,代码来源:run_once.php

示例13: list_resources

 /**
  * get a list of remote resources
  *
  * This function performs a REST call against a web services that provides a RSS-encoded response.
  *
  * Minimum example:
  * [php]
  * $result = Call::list_resources($url);
  * if(!$result[0])
  *	echo $result[1]; // error message
  * else
  *	... // use call result from $result[1]
  * [/php]
  *
  * @param string the url to use
  * @param array the parameters to transmit
  * @return an array of which the first value indicates call success or failure
  *
  * @see search.php
  */
 public static function list_resources($url, $parameters = NULL)
 {
     global $context;
     // encode the request
     $data = '';
     foreach ($parameters as $label => $value) {
         if ($data) {
             $data .= '&';
         }
         $data .= urlencode($label) . '=' . urlencode($value);
     }
     $headers = '';
     $headers .= 'Content-Type: application/x-www-form-urlencoded' . CRLF;
     $headers .= 'Content-Length: ' . strlen($data) . CRLF;
     // parse the target URL
     $items = @parse_url($url);
     // no host, assume it's us
     if (!($host = $items['host'])) {
         $host = $context['host_name'];
     }
     // no port, assume the standard
     if (!isset($items['port']) || !($port = $items['port'])) {
         $port = 80;
     }
     // outbound web is not authorized
     if (isset($context['without_outbound_http']) && $context['without_outbound_http'] == 'Y') {
         return array(FALSE, 'Outbound HTTP is not authorized.');
     }
     // connect to the server
     if (!($handle = Safe::fsockopen($host, $port, $errno, $errstr, 30))) {
         return array(FALSE, sprintf('Impossible to connect to %s.', $host . ':' . $port));
     }
     // ensure enough execution time
     Safe::set_time_limit(30);
     // build the path, including any query
     $path = $items['path'];
     if ($items['query']) {
         $path .= '?' . $items['query'];
     }
     // build an HTTP request
     $request = "POST " . $path . " HTTP/1.0" . CRLF . 'Host: ' . $host . CRLF . "Accept-Encoding: gzip" . CRLF . "User-Agent: YACS (www.yacs.fr)" . CRLF . "Connection: close" . CRLF . $headers . CRLF . $data;
     // save the request if debug mode
     if ($context['debug_call'] == 'Y') {
         Logger::remember('services/call.php: Call::list_resources() request', str_replace("\r\n", "\n", $request), 'debug');
     }
     // submit the request
     fputs($handle, $request);
     // get everything by Ethernet-sized chunks
     $response = '';
     while (!feof($handle) && strlen($response) < 5242880) {
         $response .= fread($handle, 1500);
     }
     fclose($handle);
     // ensure we have a valid HTTP status line
     if (preg_match('/^HTTP/', $response) && !preg_match('/^HTTP\\/[0-9\\.]+ 200 /', $response)) {
         $lines = explode("\n", $response, 2);
         return array(FALSE, 'Unexpected HTTP status "' . $lines[0] . '"');
     }
     // separate headers from body
     list($headers, $content) = explode(CRLF . CRLF, $response, 2);
     // uncompress payload if necessary
     if (preg_match('/Content-Encoding: \\s*gzip/i', $headers)) {
         $content = gzinflate(substr($content, 10));
     }
     // save the response if debug mode
     if ($context['debug_call'] == 'Y') {
         Logger::remember('services/call.php: Call::list_resources() response', str_replace("\r\n", "\n", $headers . "\n\n" . $content), 'debug');
     }
     // we understand only text responses
     if (!preg_match('/^Content-Type: text/m', $headers)) {
         return array(FALSE, 'Impossible to process not-textual response');
     }
     // passthrough if not xml
     if (!preg_match('/^Content-Type: text\\/xml/m', $headers)) {
         return $content;
     }
     // select a codec handler
     include_once $context['path_to_root'] . 'services/codec.php';
     include_once $context['path_to_root'] . 'services/rss_codec.php';
     $codec = new RSS_Codec();
//.........这里部分代码省略.........
开发者ID:rair,项目名称:yacs,代码行数:101,代码来源:call.php

示例14: gmdate

    Safe::rename($context['path_to_root'] . 'parameters/scripts.include.php', $context['path_to_root'] . 'parameters/scripts.include.php.bak');
    // build the new configuration file
    $content = '<?php' . "\n" . '// This file has been created by the configuration script scripts/configure.php' . "\n" . '// on ' . gmdate("F j, Y, g:i a") . ' GMT, for ' . Surfer::get_name() . '. Please do not modify it manually.' . "\n" . '$context[\'home_at_root\']=\'' . addcslashes($_REQUEST['home_at_root'], "\\'") . "';\n" . '$context[\'reference_server\']=\'' . addcslashes($_REQUEST['reference_server'], "\\'") . "';\n" . '?>' . "\n";
    // update the parameters file
    if (!Safe::file_put_contents('parameters/scripts.include.php', $content)) {
        Logger::error(sprintf(i18n::s('ERROR: Impossible to write to the file %s. The configuration has not been saved.'), 'parameters/scripts.include.php'));
        // allow for a manual update
        $context['text'] .= '<p style="text-decoration: blink;">' . sprintf(i18n::s('To actually change the configuration, please copy and paste following lines by yourself in file %s.'), 'parameters/scripts.include.php') . "</p>\n";
        // job done
    } else {
        $context['text'] .= '<p>' . sprintf(i18n::s('The following configuration has been saved into the file %s.'), 'parameters/scripts.include.php') . "</p>\n";
        // purge the cache
        Cache::clear();
        // remember the change
        $label = sprintf(i18n::c('%s has been updated'), 'parameters/scripts.include.php');
        Logger::remember('scripts/configure.php: ' . $label);
    }
    // display updated parameters
    $context['text'] .= Skin::build_box(i18n::s('Configuration parameters'), Safe::highlight_string($content), 'folded');
    // follow-up commands
    $follow_up = i18n::s('Where do you want to go now?');
    $menu = array();
    $menu = array_merge($menu, array('scripts/stage.php' => i18n::s('Stage updated scripts')));
    $menu = array_merge($menu, array('scripts/' => i18n::s('Server software')));
    $menu = array_merge($menu, array('control/' => i18n::s('Control Panel')));
    $menu = array_merge($menu, array('scripts/configure.php' => i18n::s('Configure again')));
    $follow_up .= Skin::build_list($menu, 'menu_bar');
    $context['text'] .= Skin::build_block($follow_up, 'bottom');
}
// render the skin
render_skin();
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:configure.php

示例15: sprintf

 if (!Safe::file_put_contents('parameters/root.include.php', $content)) {
     Logger::error(sprintf(i18n::s('ERROR: Impossible to write to the file %s. The configuration has not been saved.'), 'parameters/root.include.php'));
     // allow for a manual update
     $context['text'] .= '<p style="text-decoration: blink;">' . sprintf(i18n::s('To actually change the configuration, please copy and paste following lines by yourself in file %s.'), 'parameters/root.include.php') . "</p>\n";
     // job done
 } else {
     $context['text'] .= '<p>' . sprintf(i18n::s('The following configuration has been saved into the file %s.'), 'parameters/root.include.php') . "</p>\n";
     // first installation
     if (!file_exists('parameters/switch.on') && !file_exists('parameters/switch.off')) {
         $context['text'] .= '<p>' . i18n::s('Review provided information and go to the bottom of the page to move forward.') . "</a></p>\n";
     }
     // purge the cache
     Cache::clear();
     // remember the change
     $label = sprintf(i18n::c('%s has been updated'), 'parameters/root.include.php');
     Logger::remember('configure.php: ' . $label);
 }
 // display updated parameters
 $context['text'] .= Skin::build_box(i18n::s('Configuration parameters'), Safe::highlight_string($content), 'folded');
 // first installation
 if (!file_exists('parameters/switch.on') && !file_exists('parameters/switch.off')) {
     $context['text'] .= '<form method="get" action="control/" id="main_form">' . "\n" . '<p>' . Skin::build_submit_button(i18n::s('Switch the server on')) . '</p>' . "\n" . '</form>' . "\n";
     // ordinary follow-up commands
 } else {
     // what's next?
     $follow_up = i18n::s('Where do you want to go now?');
     // follow-up menu
     $menu = array();
     // front page
     $menu = array_merge($menu, array($context['url_to_root'] => i18n::s('Front page')));
     // control panel
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:configure.php


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