All pastes #940919 Raw Edit

anonym.to

public text v1 · immutable
·published 2008-03-13 11:57 UTC
rendered paste body
this installs the Anonym.to redirect on any live links in the forums on ipb 2.1.x


1. Open sources/classes/bbcode/class_bbcode.php and find:

      [CODE]
                  $txt = preg_replace( "#<a href=[\"'](http://|https://|ftp://|news://)?(\S+?)['\"].+?".">(.+?)</a>#" , "\[url=\\1\\2\]\\3\[/url\]"  , $txt );
      [/CODE]

      Add above:
      [CODE]
                  // [SnF] Referral links anonymizer 1.0.5 - anonym.to //
                  $txt = preg_replace( "#<a href=[\"'](http://anonym.to/\?)?(\S+?)['\"].+?".">(.+?)</a>#e" , "\$this->unconvert_rla(\"\\2<!--rla-->\\3\")"  , $txt );

      [/CODE]


      Now find:
      [CODE]
          /*-------------------------------------------------------------------------*/
          // OVERWRITE DEFAULT: convert_emoticon:
          /*-------------------------------------------------------------------------*/
      [/CODE]

      Add above:
      [CODE]
          // [SnF] Referral links anonymizer 1.0.5 - anonym.to //
          function unconvert_rla($rla2="")
          {

              $rla = explode("<!--rla-->",$rla2);
              $rla[0] = str_replace("%23","#",$rla[0]);

              return "<a href=\"{$rla[0]}\" target=\"_blank\">{$rla[1]}</a>";

          }
      [/CODE]
      Save and close that file.


2. Open sources/classes/bbcode/class_bbcode_core.php and find:

      [CODE]
              return $url['st'] . "<a href=\"".$url['html']."\" target=\"_blank\">".$show."</a>" . $url['end'];
      [/CODE]

      Replace with:
      [CODE]
              // [SnF] Referral links anonymizer 1.0.5 - anonym.to //
              if (ereg($this->ipsclass->vars['board_url'],$url['html']))
              {
                  return $url['st'] . "<a href='".$url['html']."' target='_blank'>".$show."</a>" . $url['end'];
              } else
              {
                  return $url['st'] . "<a href='http://anonym.to/?".str_replace("#","%23",$url['html'])."' target='_blank'>".$show."</a>" . $url['end'];
              }
      [/CODE]
      Save and close that file.


Now upload the two files to your server and it's done