⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 init.nofollow.php

📁 1. 记录每个帖子的访问人情况
💻 PHP
字号:
<?php# $Id: init.nofollow.php 11331 2005-04-15 00:02:51Z bchoate $# Released under the Artistic License# SCRiPTMAFiA 2005 - THE DiRTY HANDS ON YOUR SCRiPTSglobal $mt;$ctx = &$mt->context();# override handler for the following tags.  the overridden version# will, in turn call the MT native handlers...$ctx->register_function('MTCommentBody', 'mtcommentbody_nofollowfy');$ctx->register_function('MTCommentAuthorLink', 'mtcommentauthorlink_nofollowfy');$ctx->register_block('MTPings', 'mtpings_nofollowfy');# disable MT-forced sanitization for these tags. we'll handle it ourselves...unset($ctx->sanitized['MTCommentAuthorLink']);unset($ctx->sanitized['MTCommentBody']);$ctx->add_global_filter('nofollowfy', 'nofollowfy');function nofollow_config(&$ctx) {    $config = $ctx->stash('nofollow_config');    if ($config)        return $config;    $rows = $ctx->mt->db->get_results("select plugindata_key, plugindata_data from mt_plugindata where plugindata_plugin='Nofollow' and plugindata_key like 'configuration/%'", ARRAY_A);    $config = array();    if ($rows) {        foreach ($rows as $option) {            $param = $option['plugindata_key'];            $param = preg_replace('!^configuration/!', '', $param);            $value = $option['plugindata_data'];            $config[$param] = $value;        }    }    isset($config['nofollow_enabled']) or $config['nofollow_enabled'] = 1;    isset($config['follow_auth_links']) or $config['follow_auth_links'] = 0;    $ctx->stash('nofollow_config', $config);    return $config;}function sanitize_nofollowfy($str, $arg = 1) {    if (!isset($arg)) $arg = '1';    if ($arg) {        require_once("modifier.sanitize.php");        $str = smarty_modifier_sanitize($str, $arg);    }    return nofollowfy($str);}function nofollowfy($str, $arg = 1) {    # manipulate hyperlinks in $str...    if (!isset($str)) return $str;    if (!$arg) return $str;    return preg_replace_callback('#<a\s([^>]*\s*href\s*=[^>]*)>#i', 'nofollowfy_cb', $str);}function nofollowfy_cb($matches) {    $str = $matches[1];    preg_match_all('/[^=[:space:]]*\s*=\s*"[^"]*"|[^=[:space:]]*\s*=\s*\'[^\']*\'|[^=[:space:]]*\s*=[^[:space:]]*/', $str, $attr);    $rel_arr = preg_grep('/^rel\s*=/i', $attr[0]);    if (count($rel_arr) > 0)        $rel = array_pop($rel_arr);    if ($rel) {        $rel = preg_replace('/^(rel\s*=\s*[\'"]?)/i', '\1nofollow ', $rel);    } else {        $rel = 'rel="nofollow"';    }    $attr = preg_grep('/^rel\s*=/i', $attr[0], PREG_GREP_INVERT);    return '<a ' . join(' ', $attr) . ' ' . $rel . '>';}function mtcommentbody_nofollowfy($args, &$ctx) {    require_once("function.MTCommentBody.php");    $comment = $ctx->stash('comment');    $body = smarty_function_MTCommentBody($args, $ctx);    $config = nofollow_config($ctx);    if (!$config['nofollow_enabled']) {        require_once("modifier.sanitize.php");        if (!isset($args['sanitize'])) $args['sanitize'] = '1';        return smarty_modifier_sanitize($body, $args['sanitize']);    }    if ($comment['comment_commenter_id']) {        // is an authenticated comment        $auth = $ctx->mt->db->fetch_author($comment['comment_commenter_id']);        if ($auth && $config['follow_auth_links'])            return $body;    }    return sanitize_nofollowfy($body, $args['sanitize']);}function mtcommentauthorlink_nofollowfy($args, &$ctx) {    require_once("function.MTCommentAuthorLink.php");    if (!isset($args['no_redirect'])) $args['no_redirect'] = 1;    $link = smarty_function_MTCommentAuthorLink($args, $ctx);    $config = nofollow_config($ctx);    if (!$config['nofollow_enabled']) {        require_once("modifier.sanitize.php");        if (!isset($args['sanitize'])) $args['sanitize'] = '1';        return smarty_modifier_sanitize($link, $args['sanitize']);    }    $comment = $ctx->stash('comment');    if ($comment['comment_commenter_id']) {        // is an authenticated comment        $auth = $ctx->mt->db->fetch_author($comment['comment_commenter_id']);        if ($auth && $config['follow_auth_links'])            return $link;    }    return sanitize_nofollowfy($link, $args['sanitize']);}function mtpings_nofollowfy($args, $content, &$ctx, &$repeat) {    if (!isset($content)) require_once("block.MTPings.php");    $out = smarty_block_MTPings($args, $content, $ctx, $repeat);    $config = nofollow_config($ctx);    if ($config['nofollow_enabled'])        $out = nofollowfy($out);    return $out;}?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -