dis★rder wrote:Урока е много прост и го правя заради потребителска заявка. Състой се в това, че скрива линковете от хора които нямат регистрация и съответно виждат на мястото на линковете линк сочещ към страницата за регистрация.
1.Отворете
viewtopic.php
Намерете:
Code: Select all
$user_cache[$poster_id]['sig'] = censor_text($user_cache[$poster_id]['sig']);
Преди него добавете:
Code: Select all
if ($user->data['user_id'] == ANONYMOUS)
{
$user_cache[$poster_id]['sig'] = hide_link($user_cache[$poster_id]['sig'], $user_cache[$poster_id]['sig_bbcode_uid'], 'sig');
}
Намерете:
Преди него добавете:
Code: Select all
if ($user->data['user_id'] == ANONYMOUS)
{
$message = hide_link($message, $row['bbcode_uid']);
}
Отворете
includes/functions.php и намерете:
Преди него добавете:
Code: Select all
function hide_link($text, $uid = '', $mode = 'post')
{
if (!defined('IN_HIDE'))
{
define('IN_HIDE', true);
define('IN_SIGNATURE', false); // Hide links on signatures ? default false
define('IN_LINE_URL', true); // Hide in-line links ? default true
define('IN_BBCODE_URL', true); // Hide links into the bbcode [url][/url] default true
define('IN_BBCODE_IMG', false); // Hide links into the bbcode [img][/img] default false
define('IN_BBCODE_CODE', true); // Hide links into the bbcode [code]
default true
}
if ($mode == 'sig' && !IN_SIGNATURE)
{
return $text;
}
global $user, $phpbb_root_path, $phpEx;
global $forum_id, $topic_id, $post_id;
$redirect = array();
if ($forum_id)
{
$redirect['f'] = $forum_id;
}
if ($topic_id)
{
$redirect['t'] = $topic_id;
}
if ($post_id)
{
$redirect['p'] = $post_id;
}
$hidelink_redirect = append_sid("{$phpbb_root_path}ucp.$phpEx", "mode=login&redirect=" . urlencode(str_replace('&', '&', append_sid("{$phpbb_root_path}viewtopic.$phpEx", $redirect))));
$hidelink_search = array();
$hidelink_replace = '<span class="hidelink"><a href="' . $hidelink_redirect . '">'. $user->lang['LOGIN_EXPLAIN_VIEW'] . '</a></span>';
if (IN_BBCODE_CODE)
{
if (IN_LINE_URL)
{
// we need to turn the entities back into their original form
$entities = array("[code:$uid]", '.', ':', ':');
$characters = array("[code:$uid]\n", '.', ':', ':');
$text = str_replace($entities, $characters, $text);
$text = make_clickable($text, generate_board_url());
}
if (IN_BBCODE_URL)
{
$hidelink_search[] = "#\&\#91;url\&\#93;(.*?)\&\#91;\/url\&\#93;#is";
$hidelink_search[] = "#\&\#91;url(=(.*?))\&\#91;\/url\&\#93;#si";
$hidelink_search[] = "#\[url(=(.*))?\]([\]].*)\[/url\]#si";
}
if (IN_BBCODE_IMG)
{
$hidelink_search[] = "#\&\#91;img\&\#93;(.*?)\&\#91;\/img\&\#93;#is";
$hidelink_search[] = "#\[img\]([\]].*)\[/img\]#si";
}
}
// OK
if (IN_LINE_URL)
{
$hidelink_search[] = '#<!-- ([lmwe]) --><a class=\"(postlink|postlink-local)\" href=\"(.*?)\">(.*?)</a><!-- ([lmwe]) -->#si';
}
// OK
if (IN_BBCODE_URL)
{
$hidelink_search[] = "/\[url:$uid\](.*?)\[\/url:$uid\]/is";
$hidelink_search[] = "/\[url\=(.*?):$uid\](.*?)\[\/url:$uid\]/is";
}
// OK
if (IN_BBCODE_IMG)
{
$hidelink_search[] = "#\[img:$uid\](.*?)\[/img:$uid\]#s";
$hidelink_search[] = "#\[img\=(.*?):$uid\](.*?)\[/img:$uid\]#s";
}
$text = preg_replace ($hidelink_search, $hidelink_replace, $text);
return $text;
}
[/code]
Отворете
language/en/common.php и намерете:
След него добавете:
Code: Select all
'LOGIN_EXPLAIN_VIEW' => 'The board requires you to be registered and logged in to view links.',
Отворете
styles/prosilver/theme/colours.css и накрая добавете:
Code: Select all
/* MOD : MSSTI Hide links (V1.0.2) - Start */
code .hidelink { line-height: 2em; }
.hidelink a { border: 1px solid #cccccc; border-collapse: collapse; padding: 1px 2px; color:#ff0000; background-color: #ffffff; font-weight: normal; text-decoration: none; font-size: 1em; line-height: 1.2em;}
/* MOD : MSSTI Hide links (V1.0.2) - End */
Това е урока, след това рефрешнете темплейта и изчистете кеша.
Урока е написан от @val4o0o0