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


PHP Surfer::is_crawler方法代码示例

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


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

示例1: defined

 * This script is loaded by sections/view.php.
 *
 * If this section, or one of its anchor, specifies a specific skin (option keyword '[code]skin_xyz[/code]'),
 * or a specific variant (option keyword '[code]variant_xyz[/code]'), they are used instead default values.
 *
 * @author Bernard Paques
 * @reference
 * @license http://www.gnu.org/copyleft/lesser.txt GNU Lesser General Public License
 */
// loaded from sections/view.php
defined('YACS') or exit('Script must be included');
//
// rewrite $context['page_details'] because some details have moved to tabs
//
// do not mention details at follow-up pages, nor to crawlers
if (!$zoom_type && !Surfer::is_crawler()) {
    // one detail per line
    $text = '<p class="details">';
    $details = array();
    // add details from the overlay, if any
    if (is_object($overlay) && ($more = $overlay->get_text('details', $item))) {
        $details[] = $more;
    }
    // restricted to logged members
    if ($item['active'] == 'R') {
        $details[] = RESTRICTED_FLAG . i18n::s('Community - Access is granted to any identified surfer');
    }
    // restricted to associates
    if ($item['active'] == 'N') {
        $details[] = PRIVATE_FLAG . i18n::s('Private - Access is restricted to selected persons');
    }
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:view_as_tabs.php

示例2: load_skin

// load the skin
load_skin('categories');
// the path to this page
if (is_object($anchor) && $anchor->is_viewable()) {
    $context['path_bar'] = $anchor->get_path_bar();
} else {
    $context['path_bar'] = array('categories/' => i18n::s('Categories'));
}
// the title of the page
if (is_object($anchor)) {
    $context['page_title'] = sprintf(i18n::s('Categories for: %s'), $anchor->get_title());
} else {
    $context['page_title'] = i18n::s('Select categories for this page');
}
// 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.'));
    // not found
} elseif (!is_object($anchor)) {
    Safe::header('Status: 404 Not Found', TRUE, 404);
    Logger::error(i18n::s('No item has been found.'));
    // permission denied
} elseif (!$permitted) {
    // anonymous users are invited to log in or to register
    if (!Surfer::is_logged()) {
        Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'users/login.php?url=' . urlencode(Categories::get_url($member, 'select')));
    }
    // permission denied to authenticated user
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:select.php

示例3: join_meeting

 /**
  * remember that surfer is joining a meeting
  *
  */
 function join_meeting()
 {
     global $context;
     // sanity check
     if (!is_callable(array($this->anchor, 'get_reference'))) {
         return;
     }
     // create a comment only on first join, and if not a robot, and if comments are allowed
     if (!isset($_SESSION['event_' . $this->anchor->get_reference()]) && !Surfer::is_crawler() && !$this->anchor->has_option('no_comments')) {
         // track the new participant
         include_once $context['path_to_root'] . 'comments/comments.php';
         $fields = array();
         $fields['anchor'] = $this->anchor->get_reference();
         $fields['description'] = sprintf(i18n::s('%s has joined the meeting'), Surfer::get_name());
         $fields['type'] = 'notification';
         Comments::post($fields);
     }
     // remember that you joined the event
     $_SESSION['event_' . $this->anchor->get_reference()] = TRUE;
     // additional steps only for authenticated users
     if (!Surfer::get_id()) {
         return;
     }
     // add this page to the watching list of this surfer
     Members::assign($this->anchor->get_reference(), 'user:' . Surfer::get_id());
     // update enrolment
     include_once $context['path_to_root'] . 'shared/enrolments.php';
     enrolments::confirm($this->anchor->get_reference());
 }
开发者ID:rair,项目名称:yacs,代码行数:33,代码来源:event.php

示例4: is_visiting

 /**
  * update surfer presence
  *
  * This function is used to track presence information.
  * Errors are not reported, if any
  *
  * @param string web address of visited page
  * @param string related title
  * @param string the target anchor, if any
  * @param string level of visibility for this anchor (e.g., 'Y', 'R' or 'N')
  */
 public static function is_visiting($link, $label, $anchor = NULL, $active = 'Y')
 {
     global $context;
     // don't track crawlers
     if (Surfer::is_crawler()) {
         return;
     }
     // update the history stack
     if (!isset($context['pages_without_history']) || $context['pages_without_history'] != 'Y') {
         // put at top of stack
         if (!isset($_SESSION['visited'])) {
             $_SESSION['visited'] = array();
         }
         $_SESSION['visited'] = array_merge(array($link => $label), $_SESSION['visited']);
         // limit to 20 most recent pages
         if (count($_SESSION['visited']) > 20) {
             array_pop($_SESSION['visited']);
         }
     }
     // no anchor to remember
     if (!$anchor) {
         return;
     }
     // ensure regular operation of the server
     if (!file_exists($context['path_to_root'] . 'parameters/switch.on')) {
         return;
     }
     // nothing remembered for anonymous surfers
     if (!Surfer::get_id()) {
         return;
     }
     // we need a GET
     if (!isset($_SERVER['REQUEST_METHOD']) || $_SERVER['REQUEST_METHOD'] != 'GET') {
         return;
     }
     // Firefox pre-fetch is not a real visit
     if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch') {
         return;
     }
     // ensure the back-end is there
     if (!is_callable(array('SQL', 'query'))) {
         return;
     }
     // update the record of the surfer
     $query = "UPDATE " . SQL::table_name('users') . " SET click_anchor='" . SQL::escape($anchor) . "', click_date='" . gmstrftime('%Y-%m-%d %H:%M:%S') . "'" . " WHERE id = " . SQL::escape(Surfer::get_id());
     SQL::query($query, FALSE, $context['users_connection']);
     // also update recent visits
     include_once $context['path_to_root'] . 'users/visits.php';
     Visits::track($anchor, $active);
     // job done
     return;
 }
开发者ID:rair,项目名称:yacs,代码行数:63,代码来源:surfer.php

示例5: substr_replace


//.........这里部分代码省略.........
         $attributes .= ' accesskey="' . $access_key . '"';
     }
     // use the link as-is
     if ($variant == 'click') {
     }
     // force tip display for this link
     if ($variant == 'tip') {
         $attributes .= ' class="tip"';
         $variant = 'basic';
     }
     // malformed url '//server/path' --> 'http://server/path'
     if (!strncmp($url, '//', 2)) {
         $url = 'http:' . $url;
     } elseif (!preg_match('/^(\\/|[a-zA-Z]+:)/', $url)) {
         // email address
         if ($variant == 'email') {
             $url = 'mailto:' . $url;
         } elseif ($variant == 'script') {
         } elseif (!strncmp($url, 'ftp.', 4)) {
             $url = 'ftp://' . $url;
         } elseif (!strncmp($url, 'irc.', 4)) {
             $url = 'irc://' . $url;
         } elseif (!strncmp($url, 'nntp.', 5) || !strncmp($url, 'news.', 5)) {
             $url = 'news://' . $url;
         } elseif (!strncmp($url, 'www.', 4)) {
             $url = 'http://' . $url;
         } elseif (!strncmp($url, '#', 1)) {
             $url = $context['self_url'] . $url;
         } elseif ($variant != 'external') {
             $url = $context['url_to_root'] . $url;
         }
     }
     // help crawlers and do not count clicks
     if (is_callable(array('Surfer', 'is_crawler')) && Surfer::is_crawler()) {
         $variant = 'basic';
         $href_title = '';
         // format for a human being
     } else {
         // flag external links
         $external = $variant == 'external';
         // if no explict "external" variant but url is absolute, compare
         // it with all hosted domains to establish if its external or not
         $matches_ext = array();
         if (!$external && preg_match('/.+:\\/\\/(.+)$/', $url, $matches_ext)) {
             // the url without the protocol, begins after "://"
             $url_path = $matches_ext[1];
             // our host name, at least !
             $domains[] = $context['host_name'];
             // the master host, could be different
             $domains[] = $context['master_host'];
             // do we have hosted virtual domains ? consider them also
             if (isset($context['virtual_domains'])) {
                 $domains = array_merge($domains, $context['virtual_domains']);
             }
             // consider the url will not match ...
             $internal = FALSE;
             // compare url with each domains
             foreach ($domains as $domain) {
                 // strncomp = 0 means strings are matching
                 if (!strncmp($url_path, $domain, strlen($domain))) {
                     $internal = TRUE;
                     break;
                     // one matching is enought
                 }
             }
             $external = !$internal;
开发者ID:rair,项目名称:yacs,代码行数:67,代码来源:skin_skeleton.php

示例6: check_better_lang

 /**
  * check if a anchor with same nickname exist but with a language
  * better for the current surfer
  * if yes, redirect surfer to it
  * 
  * @see articles/view.php, sections/view.php
  * 
  * @param type $reference of the current item
  * @param type $nickname of the current item
  */
 public static function check_better_lang($reference, $nickname)
 {
     // separate class and id
     list($class, $id) = explode(":", $reference);
     // sanity check
     if (!$id || !$nickname) {
         return;
     }
     // get anchor familly
     $class = new $class();
     $familly = $class->get_static_group_class();
     // get item from nickname, will chose best language
     $anchor = $familly::get($nickname);
     // compare id, if != the redirect surfer but not crawlers
     if ($anchor['id'] !== $id && !Surfer::is_crawler()) {
         $url = $familly::get_permalink($anchor);
         Safe::redirect($url);
     }
 }
开发者ID:rair,项目名称:yacs,代码行数:29,代码来源:anchors.php

示例7: check_request

 /**
  * process one single HTTP request
  *
  * This function removes any PHPSESSID data in the query string, if any
  *
  * @return void
  *
  * @see agents/referrals_hook.php
  */
 public static function check_request()
 {
     global $context;
     // don't bother with HEAD requests
     if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'HEAD') {
         return;
     }
     // the target url
     if (!isset($_SERVER['REQUEST_URI']) || !($url = $_SERVER['REQUEST_URI'])) {
         return;
     }
     // only remember viewed pages and index pages
     if (!preg_match('/\\/(index|view).php/', $url)) {
         return;
     }
     // continue only if we have a referer
     if (!isset($_SERVER['HTTP_REFERER']) || !($referer = $_SERVER['HTTP_REFERER'])) {
         return;
     }
     // do not memorize cache referrals
     if (preg_match('/cache:/i', $referer)) {
         return;
     }
     // block pernicious attacks
     $referer = strip_tags($referer);
     // only remember external referrals
     if (preg_match('/\\b' . preg_quote(str_replace('www.', '', $context['host_name']), '/') . '\\b/i', $referer)) {
         return;
     }
     // stop crawlers
     if (Surfer::is_crawler()) {
         return;
     }
     // avoid banned sources
     include_once $context['path_to_root'] . 'servers/servers.php';
     if (preg_match(Servers::get_banned_pattern(), $referer)) {
         return;
     }
     // normalize the referral, extract keywords, and domain
     list($referer, $domain, $keywords) = Referrals::normalize($referer);
     // if a record exists for this url
     $query = "SELECT id FROM " . SQL::table_name('referrals') . " AS referrals" . " WHERE referrals.url LIKE '" . SQL::escape($url) . "' AND referrals.referer LIKE '" . SQL::escape($referer) . "'";
     if (!($item = SQL::query_first($query))) {
         return;
     }
     // update figures
     if (isset($item['id'])) {
         $query = "UPDATE " . SQL::table_name('referrals') . " SET" . " hits=hits+1," . " stamp='" . gmstrftime('%Y-%m-%d %H:%M:%S') . "'" . " WHERE id = " . $item['id'];
         // create a new record
     } else {
         // ensure the referer is accessible
         if (($content = http::proceed($referer)) === FALSE) {
             return;
         }
         // we have to find a reference to ourself in this page
         if (strpos($content, $context['url_to_home']) === FALSE) {
             return;
         }
         $query = "INSERT INTO " . SQL::table_name('referrals') . " SET" . " url='" . SQL::escape($url) . "'," . " referer='" . SQL::escape($referer) . "'," . " domain='" . SQL::escape($domain) . "'," . " keywords='" . SQL::escape($keywords) . "'," . " hits=1," . " stamp='" . gmstrftime('%Y-%m-%d %H:%M:%S') . "'";
     }
     // actual database update
     if (SQL::query($query) === FALSE) {
         return;
     }
     // prune with a probability of 1/100
     if (rand(1, 100) != 50) {
         return;
     }
     // purge oldest records -- 100 days = 8640000 seconds
     $query = "DELETE FROM " . SQL::table_name('referrals') . " WHERE stamp < '" . gmstrftime('%Y-%m-%d %H:%M:%S', time() - 8640000) . "'";
     SQL::query($query);
 }
开发者ID:rair,项目名称:yacs,代码行数:81,代码来源:referrals.php

示例8: strip_tags

     // set specific headers
     if (isset($item['introduction']) && $item['introduction']) {
         $context['page_meta'] = strip_tags(Codes::beautify_introduction($item['introduction']));
     }
     if (isset($item['create_name']) && $item['create_name']) {
         $context['page_author'] = $item['create_name'];
     }
     if (isset($item['edit_date']) && $item['edit_date']) {
         $context['page_date'] = $item['edit_date'];
     }
 }
 //
 // page details -- $context['page_details']
 //
 // do not mention details to crawlers
 if (!Surfer::is_crawler() && $whole_rendering) {
     // tags, if any
     if (isset($item['tags'])) {
         $context['page_tags'] =& Skin::build_tags($item['tags']);
     }
     // one detail per line
     $context['page_details'] .= '<p class="details">';
     $details = array();
     // add details from the overlay, if any
     if (is_object($overlay) && ($more = $overlay->get_text('details', $item))) {
         $details[] = $more;
     }
     // the capability field is displayed only to logged users
     if (!Surfer::is_logged()) {
     } elseif ($item['capability'] == 'A') {
         $details[] = i18n::s('Associate');
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:view.php

示例9: outputJSON

 * @author Alexis Raimbault
 * @reference
 * @license http://www.gnu.org/copyleft/lesser.txt GNU Lesser General Public License
 */
// common definitions and initial processing
include_once '../shared/global.php';
// ensure browser always look for fresh data
http::expire(0);
// lang
i18n::bind('files');
// stop here on scripts/validate.php
if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'HEAD') {
    return;
}
// stop if forbidden
if (Surfer::is_crawler() || !Surfer::may_upload()) {
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    die(i18n::s('You are not allowed to perform this operation.'));
}
// some input is mandatory
if (!isset($_REQUEST['name'])) {
    Safe::header('Status: 400 Bad Request', TRUE, 400);
    outputJSON(i18n::s('Request is invalid.'));
} else {
    $name = $_REQUEST['name'];
}
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
// Output JSON
function outputJSON($msg, $status = 'error', $preview = '')
{
    global $context;
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:upload.ajax.php


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