форум vBSupport.ru > vBulletin > Вопрос — Ответ
Register Меню vBsupport Изображения Files Manager О рекламе Today's Posts Search
  • Родная гавань
  • Блок РКН снят
  • Premoderation
  • For English speaking users
  • Каталог Фрилансеров
  • If you want to buy some product or script
  • Администраторам
VBsupport перешел с домена .ORG на родной .RU Ура! Пожалуйста, обновите свои закладки - VBsupport.ru
Блок РКН снят, форум доступен на всей территории России, включая новые терртории, без VPN
На форуме введена премодерация ВСЕХ новых пользователей

Почта с временных сервисов, типа mailinator.com, gawab.com и/или прочих, которые предоставляют временный почтовый ящик без регистрации и/или почтовый ящик для рассылки спама, отслеживается и блокируется, а так же заносится в спам-блок форума, аккаунты удаляются
for English speaking users:
You may be surprised with restriction of access to the attachments of the forum. The reason is the recent change in vbsupport.org strategy:

- users with reputation < 10 belong to "simple_users" users' group
- if your reputation > 10 then administrator (kerk, Luvilla) can decide to move you into an "improved" group, but only manually

Main idea is to increase motivation of community members to share their ideas and willingness to support to each other. You may write an article for the subject where you are good enough, you may answer questions, you may share vbulletin.com/org content with vbsupport.org users, receiving "thanks" equal your reputation points. We should not only consume, we should produce something.

- you may:
* increase your reputation (doing something useful for another members of community) and being improved
* purchase temporary access to the improved category:
10 $ for 3 months. - this group can download attachments, reputation/posts do not matter.
20 $ for 3 months. - this group can download attachments, reputation/posts do not matter + adds eliminated + Inbox capacity increased + files manager increased permissions.

Please contact kerk or Luvilla regarding payments.

Important!:
- if your reputation will become less then 0, you will be moved into "simple_users" users' group automatically.*
*for temporary groups (pre-paid for 3 months) reputation/posts do not matter.
Уважаемые пользователи!

На форуме открыт новый раздел "Каталог фрилансеров"

и отдельный раздел для платных заказов "Куплю/Закажу"

Если вы хотите приобрести какой то скрипт/продукт/хак из каталогов перечисленных ниже:
Каталог модулей/хаков
Ещё раз обращаем Ваше внимание: всё, что Вы скачиваете и устанавливаете на свой форум, Вы устанавливаете исключительно на свой страх и риск.
Сообщество vBSupport'а физически не в состоянии проверять все стили, хаки и нули, выкладываемые пользователями.
Помните: безопасность Вашего проекта - Ваша забота.
Убедительная просьба: при обнаружении уязвимостей или сомнительных кодов обязательно отписывайтесь в теме хака/стиля
Спасибо за понимание
 
 
 
 
DJ Kukstyler
Знаток
 
DJ Kukstyler's Avatar
Default Не работает TimeOut на Title Replace
0

Всем привет. Давно установил хак Title Replace (1.5c Replace Link With Page Title). Работает хорошо, но некоторых сайтах (как на пример mega.co.nz, облако) не может вытащить название сайта. Проблема в том, что на другом форуме я видел в работе данный хак, и там был таймаут, то есть если за х секунд не удалось добыть название сайта, просто публикуется ссылка. Однако у меня это не работает, я изменил значения timout (изначально 60) и max_redirects (изначально 10), но всё в пустую...

Знающие люди, глянте пожалуйста одним глазком, может я что-то не там меняю. Или хак просто недоработан:

PHP Code:
if (!function_exists(convert_url_to_bbcode_callback_auto_title)) {
function 
convert_url_to_bbcode_callback_auto_title($messagetext$prepend)
{
    
$messagetext str_replace('\"''"'$messagetext);
    
$prepend str_replace('\"''"'$prepend);

    static 
$urlSearchArray$urlReplaceArray$emailSearchArray$emailReplaceArray;
    if (empty(
$urlSearchArray))
    {
        
$taglist '\[b|\[i|\[u|\[left|\[center|\[right|\[indent|\[quote|\[highlight|\[\*' .
            
'|\[/b|\[/i|\[/u|\[/left|\[/center|\[/right|\[/indent|\[/quote|\[/highlight';
        
$urlSearchArray = array(
            
"#(^|(?<=[^_a-z0-9-=\]\"'/@]|(?<=" $taglist ")\]))((https?|ftp|gopher|news|telnet)://|www\.)((\[(?!/)|[^\s[^$`\"'|{}<>])+)(?!\[/url|\[/img)(?=[,.!)]*(\)\s|\)$|[\s[]|$))#siU"
        
);

        
$urlReplaceArray = array(
            
"[url]\\2\\4[/url]"
        
);

        
$emailSearchArray = array(
            
"/([ \n\r\t])([_a-z0-9-]+(\.[_a-z0-9-]+)*@[^\s]+(\.[a-z0-9-]+)*(\.[a-z]{2,4}))/si",
            
"/^([_a-z0-9-]+(\.[_a-z0-9-]+)*@[^\s]+(\.[a-z0-9-]+)*(\.[a-z]{2,4}))/si"
        
);

        
$emailReplaceArray = array(
            
"\\1[email]\\2[/email]",
            
"[email]\\0[/email]"
        
);
    }

    
$text preg_replace_callback($urlSearchArray"auto_title"$messagetext);

    if (
strpos($text"@"))
    {
        
$text preg_replace($emailSearchArray$emailReplaceArray$text);
    }

    return 
$prepend $text;
}

function 
auto_title ($text) {

$options = array( 'http' => array(
        
'user_agent'    => 'VBulletin Titletag Fetcher',
        
'max_redirects' => 3,
        
'timeout'       => 5,
    ) );
$context stream_context_create$options );

if (
$text[2] == 'www.' or $text[2] == 'Www.' or $text[2] == 'wWw.' or $text[2] == 'wwW.' or $text[2] == 'WwW.' or $text[2] == 'WWw.' or $text[2] == 'wWW.' or $text[2] == 'WWW.') { $text[4] = $text[2] . $text[4]; $text[2] = 'http://'; }

$paged    = @fopen$text[2] . $text[4], "r" ); #echo $page . "DONE"; 
if ($paged) {
    while (!
feof($paged) and ($x 1000)) { $page .= fread($paged8192); $x++; }
    
fclose($paged);
}

preg_match("/<title>[\n\r\s]*(.*)[\n\r\s]*<\/title>/"$page$title);

if (
$title[1] == '') { $title[1] = $text[2] . $text[4]; }
return 
"[url=\"" $text[2] . $text[4] . "\"]" preg_replace("/\&.+\;/"''$title[1]) . "[/url]";
}

}

    
$messagetext preg_replace(
        
'#(^|\[/(' $skiptaglist ')\])(.*(\[(' $skiptaglist ')|$))#siUe',
        
"convert_url_to_bbcode_callback_auto_title('\\3', '\\1')",
        
$messagetext
    
); 
Bot
Yandex Bot Yandex Bot is online now
 
Join Date: 05.05.2005
Реклама на форуме А что у нас тут интересного? =)
 
 
BTC
СпециалистЪ
 
BTC's Avatar
Default
1

Надо было задать вопрос в теме хака...

@DJ Kukstyler, а по делу.. юзерагент менять не пробовали, может вас ихний js скрипт меньше мурыжил и быстрее отдавал контент, хотя сайт весьма долго грузит и пинг высокий, может не хватает таймаута..
 
 
DJ Kukstyler
Знаток
 
DJ Kukstyler's Avatar
Default
0

Quote:
Originally Posted by BTC View Post
Надо было задать вопрос в теме хака...
Я подумал, что скорее всего вопрос-то тупенький (т.к. я в php в принципе не шарю совсем). По-этому ткнул сюда. Прошу прощения, если ошибся.

Quote:
Originally Posted by BTC View Post
юзерагент менять не пробовали, может вас ихний js скрипт меньше мурыжил и быстрее отдавал контент, хотя сайт весьма долго грузит и пинг высокий, может не хватает таймаута..
Нет не менял, думал, но не знаю, чем можно было бы его заменить.

Сам хак пашет хорошо, проблема в принципе пока только с сайтом Мега. Но по любому, этот таймаут не даром там указан, а работать получается не хочет. Ссылкой на https://mega.co.nz/#!VtpFjSIQ!xd_ERX...U7XuHZPkdXcWxI, оно там всё зависает, и потом в итоге ошибка fatal error timeout...

Last edited by DJ Kukstyler : 07-14-2015 at 02:52 PM.
 
 
Luvilla
Гость
Default

Quote:
Originally Posted by BTC View Post
Надо было задать вопрос в теме хака...
а где он? я перенесу посты
 
 
BTC
СпециалистЪ
 
BTC's Avatar
Default
0

Luvilla, на слово "теме" наведи, я указал хреф.
 
 
Luvilla
Гость
Default

Quote:
Originally Posted by BTC View Post
на слово "теме" наведи
совсем слепая стала.... а это точно он?
 
 
BTC
СпециалистЪ
 
BTC's Avatar
Default
0

Luvilla,

Аттач по линку: _http://vbsupport.ru/forum/showthread.php?t=41285
PHP Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<product productid="Title Replace" active="1">
    <title>Title Replace</title>
    <description>Replace Link With Page Title</description>
    <version>1.5c</version>
    <url>http://www.vbulletin.org/forum/showthread.php?t=189658</url>
    <versioncheckurl />
    <versioncheckurl><![CDATA[http://www.vbulletin.org/forum/misc.php?do=checkversion&t=189658]]></versioncheckurl>
    <dependencies>
        <dependency dependencytype="vbulletin" minversion="3.6.0" maxversion="4.0.0 alpha 1" />
    </dependencies>

<plugins>
    <plugin active="1" product="Title Replace">
        <title>Title_Replace</title>
        <hookname>url_to_bbcode</hookname>
        <phpcode><![CDATA[if (!function_exists(convert_url_to_bbcode_callback_auto_title)) {
function convert_url_to_bbcode_callback_auto_title($messagetext, $prepend)
{
    $messagetext = str_replace('\"', '"', $messagetext);
    $prepend = str_replace('\"', '"', $prepend);

    static $urlSearchArray, $urlReplaceArray, $emailSearchArray, $emailReplaceArray;
    if (empty($urlSearchArray))
    {
        $taglist = '\[b|\[i|\[u|\[left|\[center|\[right|\[indent|\[quote|\[highlight|\[\*' .
            '|\[/b|\[/i|\[/u|\[/left|\[/center|\[/right|\[/indent|\[/quote|\[/highlight';
        $urlSearchArray = array(
            "#(^|(?<=[^_a-z0-9-=\]\"'/@]|(?<=" . $taglist . ")\]))((https?|ftp|gopher|news|telnet)://|www\.)((\[(?!/)|[^\s[^$`\"'|{}<>])+)(?!\[/url|\[/img)(?=[,.!)]*(\)\s|\)$|[\s[]|$))#siU"
        );

        $urlReplaceArray = array(
            "[url]\\2\\4[/url]"
        );

        $emailSearchArray = array(
            "/([ \n\r\t])([_a-z0-9-]+(\.[_a-z0-9-]+)*@[^\s]+(\.[a-z0-9-]+)*(\.[a-z]{2,4}))/si",
            "/^([_a-z0-9-]+(\.[_a-z0-9-]+)*@[^\s]+(\.[a-z0-9-]+)*(\.[a-z]{2,4}))/si"
        );

        $emailReplaceArray = array(
            "\\1[email]\\2[/email]",
            "[email]\\0[/email]"
        );
    }

    $text = preg_replace_callback($urlSearchArray, "auto_title", $messagetext);

    if (strpos($text, "@"))
    {
        $text = preg_replace($emailSearchArray, $emailReplaceArray, $text);
    }

    return $prepend . $text;
}

function auto_title ($text) {

$options = array( 'http' => array(
        'user_agent'    => 'VBulletin Titletag Fetcher',
        'max_redirects' => 10,
        'timeout'       => 60,
    ) );
$context = stream_context_create( $options );

if ($text[2] == 'www.' or $text[2] == 'Www.' or $text[2] == 'wWw.' or $text[2] == 'wwW.' or $text[2] == 'WwW.' or $text[2] == 'WWw.' or $text[2] == 'wWW.' or $text[2] == 'WWW.') { $text[4] = $text[2] . $text[4]; $text[2] = 'http://'; }

$paged    = @fopen( $text[2] . $text[4], "r" ); #echo $page . "DONE"; 
if ($paged) {
    while (!feof($paged) and ($x < 1000)) { $page .= fread($paged, 8192); $x++; }
    fclose($paged);
}

preg_match("/<title>[\n\r\s]*(.*)[\n\r\s]*<\/title>/", $page, $title);

if ($title[1] == '') { $title[1] = $text[2] . $text[4]; }
return "[url=\"" . $text[2] . $text[4] . "\"]" . preg_replace("/\&.+\;/", '', $title[1]) . "[/url]";
}

}

    $messagetext = preg_replace(
        '#(^|\[/(' . $skiptaglist . ')\])(.*(\[(' . $skiptaglist . ')|$))#siUe',
        "convert_url_to_bbcode_callback_auto_title('\\3', '\\1')",
        $messagetext
    );
]]></phpcode>
    </plugin>
</plugins>
</product>
и код из первого поста этой темы:
PHP Code:
if (!function_exists(convert_url_to_bbcode_callback_auto_title)) { 
function 
convert_url_to_bbcode_callback_auto_title($messagetext$prepend

    
$messagetext str_replace('\"''"'$messagetext); 
    
$prepend str_replace('\"''"'$prepend); 

    static 
$urlSearchArray$urlReplaceArray$emailSearchArray$emailReplaceArray
    if (empty(
$urlSearchArray)) 
    { 
        
$taglist '\[b|\[i|\[u|\[left|\[center|\[right|\[indent|\[quote|\[highlight|\[\*' 
            
'|\[/b|\[/i|\[/u|\[/left|\[/center|\[/right|\[/indent|\[/quote|\[/highlight'
        
$urlSearchArray = array( 
            
"#(^|(?<=[^_a-z0-9-=\]\"'/@]|(?<=" $taglist ")\]))((https?|ftp|gopher|news|telnet)://|www\.)((\[(?!/)|[^\s[^$`\"'|{}<>])+)(?!\[/url|\[/img)(?=[,.!)]*(\)\s|\)$|[\s[]|$))#siU" 
        
); 

        
$urlReplaceArray = array( 
            
"[url]\\2\\4[/url]" 
        
); 

        
$emailSearchArray = array( 
            
"/([ \n\r\t])([_a-z0-9-]+(\.[_a-z0-9-]+)*@[^\s]+(\.[a-z0-9-]+)*(\.[a-z]{2,4}))/si"
            
"/^([_a-z0-9-]+(\.[_a-z0-9-]+)*@[^\s]+(\.[a-z0-9-]+)*(\.[a-z]{2,4}))/si" 
        
); 

        
$emailReplaceArray = array( 
            
"\\1[email]\\2[/email]"
            
"[email]\\0[/email]" 
        
); 
    } 

    
$text preg_replace_callback($urlSearchArray"auto_title"$messagetext); 

    if (
strpos($text"@")) 
    { 
        
$text preg_replace($emailSearchArray$emailReplaceArray$text); 
    } 

    return 
$prepend $text


function 
auto_title ($text) { 

$options = array( 'http' => array( 
        
'user_agent'    => 'VBulletin Titletag Fetcher'
        
'max_redirects' => 3
        
'timeout'       => 5
    ) ); 
$context stream_context_create$options ); 

if (
$text[2] == 'www.' or $text[2] == 'Www.' or $text[2] == 'wWw.' or $text[2] == 'wwW.' or $text[2] == 'WwW.' or $text[2] == 'WWw.' or $text[2] == 'wWW.' or $text[2] == 'WWW.') { $text[4] = $text[2] . $text[4]; $text[2] = 'http://'; } 

$paged    = @fopen$text[2] . $text[4], "r" ); #echo $page . "DONE";  
if ($paged) { 
    while (!
feof($paged) and ($x 1000)) { $page .= fread($paged8192); $x++; } 
    
fclose($paged); 


preg_match("/<title>[\n\r\s]*(.*)[\n\r\s]*<\/title>/"$page$title); 

if (
$title[1] == '') { $title[1] = $text[2] . $text[4]; } 
return 
"[url=\"" $text[2] . $text[4] . "\"]" preg_replace("/\&.+\;/"''$title[1]) . "[/url]"




    
$messagetext preg_replace
        
'#(^|\[/(' $skiptaglist ')\])(.*(\[(' $skiptaglist ')|$))#siUe'
        
"convert_url_to_bbcode_callback_auto_title('\\3', '\\1')"
        
$messagetext 
    
); 

Заставила меня усомнится в моей памяти...
 
 
kerk
k0t
 
kerk's Avatar
Default
1

это кто ж такой гений?
PHP Code:
if ($text[2] == 'www.' or $text[2] == 'Www.' or $text[2] == 'wWw.' or $text[2] == 'wwW.' or $text[2] == 'WwW.' or $text[2] == 'WWw.' or $text[2] == 'wWW.' or $text[2] == 'WWW.'
а вот так нельзя?
PHP Code:
$text[2] = strtolower($text[2]); 
или использовать регулярку а не тупое сравнение, всевозможных вариаций www
 
 
Catlord Meow
Специалист
 
Catlord Meow's Avatar
Default
1

Quote:
Originally Posted by DJ Kukstyler View Post
Однако у меня это не работает, я изменил значения timout (изначально 60) и max_redirects (изначально 10), но всё в пустую...
Да, не работает, и в таком виде -- и не будет .
В изначальной версии аддона имеется баг -- обратите внимание, значение переменной $context хоть и присваивается, но дальше эта переменная нигде не используется.
Хоть она должна, она обязана быть передана в функцию fopen:
http://php.net/manual/ru/function.st...ext-create.php

Весь код для таймаута и юзерагента работает вхолостую.

Исправленная версия здесь:
http://vbsupport.ru/forum/showthread.php?t=52501

Last edited by Catlord Meow : 08-10-2016 at 07:13 PM.
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off




All times are GMT +4. The time now is 09:09 AM.


Powered by vBulletin® Version 3.0.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.