/** * notify servers about a new page * * @param string page URL * @param string server name */ public static function notify($link, $title = NULL) { global $context; if (!$title) { $title = $context['site_name']; } // the list of recipients contacted during overall script execution if (!isset($context['servers_endpoints'])) { $context['servers_endpoints'] = array(); } // list servers to be advertised if ($servers = Servers::list_for_ping(0, COMPACT_LIST_SIZE, 'ping')) { // ping each server include_once $context['path_to_root'] . 'services/call.php'; foreach ($servers as $server_url => $attributes) { list($server_ping, $server_label) = $attributes; $milestone = get_micro_time(); $result = Call::invoke($server_ping, 'weblogUpdates.ping', array(strip_tags($title), $context['url_to_home'] . $context['url_to_root'] . $link), 'XML-RPC'); if ($result[0]) { $server_label .= ' (' . round(get_micro_time() - $milestone, 2) . ' sec.)'; } $context['servers_endpoints'][] = $server_label; } } }
// the title of the page $context['page_title'] = i18n::s('Ping the cloud'); // stop crawlers if (Surfer::is_crawler()) { Safe::header('Status: 401 Unauthorized', TRUE, 401); Logger::error(i18n::s('You are not allowed to perform this operation.')); // anonymous users are invited to log in or to register } elseif (!Surfer::is_logged()) { Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'users/login.php?url=' . urlencode('servers/ping.php')); } elseif (!Surfer::is_associate()) { Safe::header('Status: 401 Unauthorized', TRUE, 401); Logger::error(i18n::s('You are not allowed to perform this operation.')); // do the ping } elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'ping') { // list servers to be advertised if ($servers = Servers::list_for_ping(0, 20, 'ping')) { $context['text'] .= '<p>' . i18n::s('Servers that have been notified') . '</p><ul>'; // ping each server foreach ($servers as $server_url => $attributes) { 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
// trackback option $label = i18n::s('Trackback'); $input = '<input type="radio" name="trackback_option" value="N"'; if (!$trackback_option) { $input .= ' checked="checked"'; } $input .= '/> ' . i18n::s('Do not contact referenced servers') . BR . '<input type="radio" name="trackback_option" value="Y"'; if ($trackback_option) { $input .= ' checked="checked"'; } $input .= '/> ' . i18n::s('Parse links and trackback referenced pages'); $fields[] = array($label, $input); // ping option $label = i18n::s('Ping'); // list servers to be advertised if ($servers = Servers::list_for_ping(0, COMPACT_LIST_SIZE, 'ping')) { // list targeted servers $list = '<ul>'; foreach ($servers as $server_url => $attributes) { list($server_ping, $server_label) = $attributes; $list .= '<li>' . Skin::build_link($server_url, $server_label, 'external') . '</li>'; } $list .= '</ul>'; $input = '<input type="radio" name="ping_option" value="N"'; if (!$ping_option) { $input .= ' checked="checked"'; } $input .= '/> ' . i18n::s('Do not contact aggregation servers') . BR . '<input type="radio" name="ping_option" value="Y"'; if ($ping_option) { $input .= ' checked="checked"'; }