MOD Autolinks

Zde prosím diskutujme otázky okolo správy skupin, oprávnění a členění fóra. Zde umísťujte i vzkazy správcům fóra. Správa fóra je komplexní záležitost a vyžaduje Vaši spolupráci.

Moderátor: Administrativní odbor

Odpovědět
Uživatelský avatar
Jiri.Kaderavek
Republikový výbor
Příspěvky: 8030
Registrován: 21 dub 2009, 12:58
Profese: programátor, hoteliér, manažer, trenér
Dal poděkování: 2793 poděkování
Dostal poděkování: 8202 poděkování
Kontaktovat uživatele:

MOD Autolinks

Příspěvek od Jiri.Kaderavek »

Nainstaloval jsem mod Autolinks, umožňuje nahrazovat ustálené výrazy příslušnými odkazy. Např. takové ČPS nebo IMHO ...
Přidávejte návrhy na nové autolinky, časem to shrnu a dle uvážení doplním.
Zakladatel České pirátské strany
Svobodu nekoupíte, tu si volíte
https://lide.pirati.cz/personProfile/96/
Uživatelský avatar
Jiri.Kaderavek
Republikový výbor
Příspěvky: 8030
Registrován: 21 dub 2009, 12:58
Profese: programátor, hoteliér, manažer, trenér
Dal poděkování: 2793 poděkování
Dostal poděkování: 8202 poděkování
Kontaktovat uživatele:

Re: MOD Autolinks

Příspěvek od Jiri.Kaderavek »

Patch na case sensitivity

Kód: Vybrat vše

diff -x '*cache/*' -x config.php -x '*files*' -x '*download*' -crB forum/includes/cache.php forum_new/includes/cache.php
*** forum/includes/cache.php    Fri Nov 20 12:07:23 2009
--- forum_new/includes/cache.php        Fri Nov 20 12:10:35 2009
***************
*** 455,462 ****
                                $result = $db->sql_query($sql);
                                while($row = $db->sql_fetchrow($result))
                                {
!                                       $th23_autolinks['pattern'][strtolower($row['username'])] = '#(?<!\w)(' . str_replace('\*', '\w*?', preg_quote($row['username'], '#')) . ')(?!\w)#i';
!                                       $th23_autolinks['replacement'][strtolower($row['username'])] = 'th23autolink_rootmemberlist.php?mode=viewprofile&u=' . $row['user_id'] . 'th23autolink_sid_and';
                                }
                                $db->sql_freeresult($result);
                        }
--- 455,462 ----
                                $result = $db->sql_query($sql);
                                while($row = $db->sql_fetchrow($result))
                                {
!                                       $th23_autolinks['pattern'][strtolower($row['username'])] = '#(?<!\w)(' . str_replace('\*', '\w*?', preg_quote($row['username'], '#')) . ')(?!\w)#';
!                                       $th23_autolinks['replacement'][strtolower($row['username'])] = 'th23autolink_rootmemberlist.php?mode=viewprofile&u=' . $row['user_id'] . 'th23autolink_sid_and';
                                }
                                $db->sql_freeresult($result);
                        }
***************
*** 466,473 ****
                        $result = $db->sql_query($sql);
                        while($row = $db->sql_fetchrow($result))
                        {
!                               $th23_autolinks['pattern'][strtolower($row['text'])] = '#(?<!\w)(' . str_replace('\*', '\w*?', preg_quote($row['text'], '#')) . ')(?!\w)#i';
!                               $th23_autolinks['replacement'][strtolower($row['text'])] = $row['url'];
                        }
                        $db->sql_freeresult($result);

--- 466,473 ----
                        $result = $db->sql_query($sql);
                        while($row = $db->sql_fetchrow($result))
                        {
!                               $th23_autolinks['pattern'][strtolower($row['text'])] = '#(?<!\w)(' . str_replace('\*', '\w*?', preg_quote($row['text'], '#')) . ')(?!\w)#';
!                               $th23_autolinks['replacement'][$row['text']] = $row['url'];
                        }
                        $db->sql_freeresult($result);

A ještě jeden patch, chyba linkování interních odkazů.

Kód: Vybrat vše

diff -x '*cache/*' -x config.php -x '*files*' -x '*download*' -crB forum/includes/th23_autolinks.php forum_new/includes/th23_autolinks.php
*** forum/includes/th23_autolinks.php   Fri Nov 20 11:17:36 2009
--- forum_new/includes/th23_autolinks.php       Fri Nov 20 13:31:22 2009
***************
*** 28,35 ****
  // prepare root path and session id for local links
  $th23_autolinks_local = array(
        'search' => array(
!               'th23autolink_root',
!               'th23autolink_sid_and',
                'th23autolink_sid_que',
        ),
        'replace' => array(
--- 28,35 ----
  // prepare root path and session id for local links
  $th23_autolinks_local = array(
        'search' => array(
!               'th23autolink_root',
!               'th23autolink_sid_and',
                'th23autolink_sid_que',
        ),
        'replace' => array(
***************
*** 51,94 ****

        // convert standard bbcodes tags to secure them from being linked
        $search = array(
!               '[i:' . $th23_autolinks_uid . ']',
!               '[/i:' . $th23_autolinks_uid . ']',
!               '[u:' . $th23_autolinks_uid . ']',
!               '[/u:' . $th23_autolinks_uid . ']',
!               '[b:' . $th23_autolinks_uid . ']',
!               '[/b:' . $th23_autolinks_uid . ']',
!               '[*:' . $th23_autolinks_uid . ']',
!               '[/*:m:' . $th23_autolinks_uid . ']',
!               '[/quote:' . $th23_autolinks_uid . ']',
!               '[/list:o:' . $th23_autolinks_uid . ']',
!               '[/list:u:' . $th23_autolinks_uid . ']',
!               '[/color' . $th23_autolinks_uid . ']',
!               '[/size' . $th23_autolinks_uid . ']',
        );
        $replace = array(
!               ' th23autolink_bbcode_start_i_' . $th23_autolinks_uid . ' ',
!               ' th23autolink_bbcode_end_i_' . $th23_autolinks_uid . ' ',
!               ' th23autolink_bbcode_start_u_' . $th23_autolinks_uid . ' ',
!               ' th23autolink_bbcode_end_u_' . $th23_autolinks_uid . ' ',
!               ' th23autolink_bbcode_start_b_' . $th23_autolinks_uid . ' ',
!               ' th23autolink_bbcode_end_b_' . $th23_autolinks_uid . ' ',
!               ' th23autolink_bbcode_start_star_' . $th23_autolinks_uid . ' ',
!               ' th23autolink_bbcode_end_star_' . $th23_autolinks_uid . ' ',
!               ' th23autolink_bbcode_end_quote_' . $th23_autolinks_uid . ' ',
!               ' th23autolink_bbcode_end_list_o_' . $th23_autolinks_uid . ' ',
!               ' th23autolink_bbcode_end_list_u_' . $th23_autolinks_uid . ' ',
!               ' th23autolink_bbcode_end_color_' . $th23_autolinks_uid . ' ',
!               ' th23autolink_bbcode_end_size_' . $th23_autolinks_uid . ' ',
        );
        if ($config['th23_autolinks_code'])
        {
!               $search[] = '[code:' . $th23_autolinks_uid . ']';
!               $search[] = '[/code:' . $th23_autolinks_uid . ']';
!               $replace[] = ' th23autolink_bbcode_start_code_' . $th23_autolinks_uid . ' ';
!               $replace[] = ' th23autolink_bbcode_end_code_' . $th23_autolinks_uid . ' ';
        }
        $text = str_replace($search, $replace, $text);
!
        // encode img, url, flash, attachment, smilies (incl. start/end tag)
        // and encode start tag of quote, list, color, size
        $search = array(
--- 51,94 ----

        // convert standard bbcodes tags to secure them from being linked
        $search = array(
!               '[i:' . $th23_autolinks_uid . ']',
!               '[/i:' . $th23_autolinks_uid . ']',
!               '[u:' . $th23_autolinks_uid . ']',
!               '[/u:' . $th23_autolinks_uid . ']',
!               '[b:' . $th23_autolinks_uid . ']',
!               '[/b:' . $th23_autolinks_uid . ']',
!               '[*:' . $th23_autolinks_uid . ']',
!               '[/*:m:' . $th23_autolinks_uid . ']',
!               '[/quote:' . $th23_autolinks_uid . ']',
!               '[/list:o:' . $th23_autolinks_uid . ']',
!               '[/list:u:' . $th23_autolinks_uid . ']',
!               '[/color' . $th23_autolinks_uid . ']',
!               '[/size' . $th23_autolinks_uid . ']',
        );
        $replace = array(
!               ' th23autolink_bbcode_start_i_' . $th23_autolinks_uid . ' ',
!               ' th23autolink_bbcode_end_i_' . $th23_autolinks_uid . ' ',
!               ' th23autolink_bbcode_start_u_' . $th23_autolinks_uid . ' ',
!               ' th23autolink_bbcode_end_u_' . $th23_autolinks_uid . ' ',
!               ' th23autolink_bbcode_start_b_' . $th23_autolinks_uid . ' ',
!               ' th23autolink_bbcode_end_b_' . $th23_autolinks_uid . ' ',
!               ' th23autolink_bbcode_start_star_' . $th23_autolinks_uid . ' ',
!               ' th23autolink_bbcode_end_star_' . $th23_autolinks_uid . ' ',
!               ' th23autolink_bbcode_end_quote_' . $th23_autolinks_uid . ' ',
!               ' th23autolink_bbcode_end_list_o_' . $th23_autolinks_uid . ' ',
!               ' th23autolink_bbcode_end_list_u_' . $th23_autolinks_uid . ' ',
!               ' th23autolink_bbcode_end_color_' . $th23_autolinks_uid . ' ',
!               ' th23autolink_bbcode_end_size_' . $th23_autolinks_uid . ' ',
        );
        if ($config['th23_autolinks_code'])
        {
!               $search[] = '[code:' . $th23_autolinks_uid . ']';
!               $search[] = '[/code:' . $th23_autolinks_uid . ']';
!               $replace[] = ' th23autolink_bbcode_start_code_' . $th23_autolinks_uid . ' ';
!               $replace[] = ' th23autolink_bbcode_end_code_' . $th23_autolinks_uid . ' ';
        }
        $text = str_replace($search, $replace, $text);
!
        // encode img, url, flash, attachment, smilies (incl. start/end tag)
        // and encode start tag of quote, list, color, size
        $search = array(
***************
*** 96,102 ****
                '/\[url.*?:' . $th23_autolinks_uid . '\].*?\[\/url:' . $th23_autolinks_uid . '\]/i',
                '/\[flash.*?:' . $th23_autolinks_uid . '\].*?\[\/flash:' . $th23_autolinks_uid . '\]/i',
                '/\[attachment.*?:' . $th23_autolinks_uid . '\].*?\[\/attachment:' . $th23_autolinks_uid . '\]/i',
!               '/(<!-- s:.*?: -->)<img.*?\/>\1/i',
                '/(<!-- m -->).*?\1/i',
                '/(<!-- l -->).*?\1/i',
                '/(<!-- w -->).*?\1/i',
--- 96,102 ----
                '/\[url.*?:' . $th23_autolinks_uid . '\].*?\[\/url:' . $th23_autolinks_uid . '\]/i',
                '/\[flash.*?:' . $th23_autolinks_uid . '\].*?\[\/flash:' . $th23_autolinks_uid . '\]/i',
                '/\[attachment.*?:' . $th23_autolinks_uid . '\].*?\[\/attachment:' . $th23_autolinks_uid . '\]/i',
!               '/(<!-- s:.*?: -->)<img.*?\/>\1/i',
                '/(<!-- m -->).*?\1/i',
                '/(<!-- l -->).*?\1/i',
                '/(<!-- w -->).*?\1/i',
***************
*** 121,161 ****

        // re-convert standard bbcodes tags
        $search = array(
!               ' th23autolink_bbcode_start_i_' . $th23_autolinks_uid . ' ',
!               ' th23autolink_bbcode_end_i_' . $th23_autolinks_uid . ' ',
!               ' th23autolink_bbcode_start_u_' . $th23_autolinks_uid . ' ',
!               ' th23autolink_bbcode_end_u_' . $th23_autolinks_uid . ' ',
!               ' th23autolink_bbcode_start_b_' . $th23_autolinks_uid . ' ',
!               ' th23autolink_bbcode_end_b_' . $th23_autolinks_uid . ' ',
!               ' th23autolink_bbcode_start_star_' . $th23_autolinks_uid . ' ',
!               ' th23autolink_bbcode_end_star_' . $th23_autolinks_uid . ' ',
!               ' th23autolink_bbcode_end_quote_' . $th23_autolinks_uid . ' ',
!               ' th23autolink_bbcode_end_list_o_' . $th23_autolinks_uid . ' ',
!               ' th23autolink_bbcode_end_list_u_' . $th23_autolinks_uid . ' ',
!               ' th23autolink_bbcode_end_color_' . $th23_autolinks_uid . ' ',
!               ' th23autolink_bbcode_end_size_' . $th23_autolinks_uid . ' ',
        );
        $replace = array(
!               '[i:' . $th23_autolinks_uid . ']',
!               '[/i:' . $th23_autolinks_uid . ']',
!               '[u:' . $th23_autolinks_uid . ']',
!               '[/u:' . $th23_autolinks_uid . ']',
!               '[b:' . $th23_autolinks_uid . ']',
!               '[/b:' . $th23_autolinks_uid . ']',
!               '[*:' . $th23_autolinks_uid . ']',
!               '[/*:m:' . $th23_autolinks_uid . ']',
!               '[/quote:' . $th23_autolinks_uid . ']',
!               '[/list:o:' . $th23_autolinks_uid . ']',
!               '[/list:u:' . $th23_autolinks_uid . ']',
!               '[/color' . $th23_autolinks_uid . ']',
!               '[/size' . $th23_autolinks_uid . ']',
        );
        if ($config['th23_autolinks_code'])
        {
!               $search[] = ' th23autolink_bbcode_start_code_' . $th23_autolinks_uid . ' ';
!               $search[] = ' th23autolink_bbcode_end_code_' . $th23_autolinks_uid . ' ';
!               $replace[] = '[code:' . $th23_autolinks_uid . ']';
!               $replace[] = '[/code:' . $th23_autolinks_uid . ']';
        }
        $text = str_replace($search, $replace, $text);

--- 121,161 ----

        // re-convert standard bbcodes tags
        $search = array(
!               ' th23autolink_bbcode_start_i_' . $th23_autolinks_uid . ' ',
!               ' th23autolink_bbcode_end_i_' . $th23_autolinks_uid . ' ',
!               ' th23autolink_bbcode_start_u_' . $th23_autolinks_uid . ' ',
!               ' th23autolink_bbcode_end_u_' . $th23_autolinks_uid . ' ',
!               ' th23autolink_bbcode_start_b_' . $th23_autolinks_uid . ' ',
!               ' th23autolink_bbcode_end_b_' . $th23_autolinks_uid . ' ',
!               ' th23autolink_bbcode_start_star_' . $th23_autolinks_uid . ' ',
!               ' th23autolink_bbcode_end_star_' . $th23_autolinks_uid . ' ',
!               ' th23autolink_bbcode_end_quote_' . $th23_autolinks_uid . ' ',
!               ' th23autolink_bbcode_end_list_o_' . $th23_autolinks_uid . ' ',
!               ' th23autolink_bbcode_end_list_u_' . $th23_autolinks_uid . ' ',
!               ' th23autolink_bbcode_end_color_' . $th23_autolinks_uid . ' ',
!               ' th23autolink_bbcode_end_size_' . $th23_autolinks_uid . ' ',
        );
        $replace = array(
!               '[i:' . $th23_autolinks_uid . ']',
!               '[/i:' . $th23_autolinks_uid . ']',
!               '[u:' . $th23_autolinks_uid . ']',
!               '[/u:' . $th23_autolinks_uid . ']',
!               '[b:' . $th23_autolinks_uid . ']',
!               '[/b:' . $th23_autolinks_uid . ']',
!               '[*:' . $th23_autolinks_uid . ']',
!               '[/*:m:' . $th23_autolinks_uid . ']',
!               '[/quote:' . $th23_autolinks_uid . ']',
!               '[/list:o:' . $th23_autolinks_uid . ']',
!               '[/list:u:' . $th23_autolinks_uid . ']',
!               '[/color' . $th23_autolinks_uid . ']',
!               '[/size' . $th23_autolinks_uid . ']',
        );
        if ($config['th23_autolinks_code'])
        {
!               $search[] = ' th23autolink_bbcode_start_code_' . $th23_autolinks_uid . ' ';
!               $search[] = ' th23autolink_bbcode_end_code_' . $th23_autolinks_uid . ' ';
!               $replace[] = '[code:' . $th23_autolinks_uid . ']';
!               $replace[] = '[/code:' . $th23_autolinks_uid . ']';
        }
        $text = str_replace($search, $replace, $text);

***************
*** 173,179 ****
  function th23_autolinks_encode_links($match)
  {
        global $th23_autolinks, $th23_autolinks_css, $th23_autolinks_title, $th23_autolinks_local, $th23_autolinks_uid;
!       return ' th23autolink_encode_start_' . $th23_autolinks_uid . base64_encode('<a href="' . str_replace($th23_autolinks_local['search'], $th23_autolinks_local['replace'], $th23_autolinks['replacement'][strtolower($match[1])]) . '"' . $th23_autolinks_css . $th23_autolinks_title . '>' . $match[1] . '</a>') . 'th23autolink_encode_end_' . $th23_autolinks_uid . ' ';
  }

  // decode the encoded links and smilies to display them properly
--- 173,179 ----
  function th23_autolinks_encode_links($match)
  {
        global $th23_autolinks, $th23_autolinks_css, $th23_autolinks_title, $th23_autolinks_local, $th23_autolinks_uid;
!       return ' th23autolink_encode_start_' . $th23_autolinks_uid . base64_encode('<a href="' . ereg_replace('^\./http', 'http', str_replace($th23_autolinks_local['search'], $th23_autolinks_local['replace'], $th23_autolinks['replacement'][strtolower($match[1])])) . '"' . $th23_autolinks_css . $th23_autolinks_title . '>' . $match[1] . '</a>') . 'th23autolink_encode_end_' . $th23_autolinks_uid . ' ';
  }

  // decode the encoded links and smilies to display them properly

a možnost zadavat za svislytkem popisek odkazu

Kód: Vybrat vše

diff -x '*cache/*' -x config.php -x '*files*' -x '*download*' -crB forum/includes/th23_autolinks.php forum_new/includes/th23_autolinks.php
*** forum/includes/th23_autolinks.php   Fri Nov 20 13:33:13 2009
--- forum_new/includes/th23_autolinks.php       Fri Nov 20 13:46:48 2009
***************
*** 173,179 ****
  function th23_autolinks_encode_links($match)
  {
        global $th23_autolinks, $th23_autolinks_css, $th23_autolinks_title, $th23_autolinks_local, $th23_autolinks_uid;
!       return ' th23autolink_encode_start_' . $th23_autolinks_uid . base64_encode('<a href="' . ereg_replace('^\./http', 'http', str_replace($th23_autolinks_local['search'], $th23_autolinks_local['replace'], $th23_autolinks['replacement'][strtolower($match[1])])) . '"' . $th23_autolinks_css . $th23_autolinks_title . '>' . $match[1] . '</a>') . 'th23autolink_encode_end_' . $th23_autolinks_uid . ' ';
  }

  // decode the encoded links and smilies to display them properly
--- 173,179 ----
  function th23_autolinks_encode_links($match)
  {
        global $th23_autolinks, $th23_autolinks_css, $th23_autolinks_title, $th23_autolinks_local, $th23_autolinks_uid;
!       return ' th23autolink_encode_start_' . $th23_autolinks_uid . base64_encode('<a href="' . ereg_replace('\|', '" title="', ereg_replace('^\./http', 'http', str_replace($th23_autolinks_local['search'], $th23_autolinks_local['replace'], $th23_autolinks['replacement'][strtolower($match[1])]))) . '"' . $th23_autolinks_css . '>' . $match[1] . '</a>') . 'th23autolink_encode_end_' . $th23_autolinks_uid . ' ';
  }

  // decode the encoded links and smilies to display them properly
Zakladatel České pirátské strany
Svobodu nekoupíte, tu si volíte
https://lide.pirati.cz/personProfile/96/
Uživatelský avatar
next_ghost
Návštěvník – nepatří k Pirátům
Příspěvky: 3239
Registrován: 21 dub 2009, 18:03
Profese: programátor
Dal poděkování: 1433 poděkování
Dostal poděkování: 5131 poděkování
Kontaktovat uživatele:

Re: MOD Autolinks

Příspěvek od next_ghost »

Má to ale jednu drobnou chybku - uživatelská jména nahrazuje za odkazy na profil. Kdyz pak clovek pise cesky, má z člověka odkaz. :lol:

Chceš, aby organizace fungovala? Komunikuj!
Česká pirátská strana: Neškodná.

Uživatelský avatar
Jiri.Kaderavek
Republikový výbor
Příspěvky: 8030
Registrován: 21 dub 2009, 12:58
Profese: programátor, hoteliér, manažer, trenér
Dal poděkování: 2793 poděkování
Dostal poděkování: 8202 poděkování
Kontaktovat uživatele:

Re: MOD Autolinks

Příspěvek od Jiri.Kaderavek »

Tohle vypnu, ještě by se někdo registroval jen kvůli tomu, aby to linkovalo jeho profil.
Zakladatel České pirátské strany
Svobodu nekoupíte, tu si volíte
https://lide.pirati.cz/personProfile/96/
Odpovědět

Zpět na „Správa fóra“