Extension:Links

From MediaWiki.org

Jump to: navigation, search
Manual on MediaWiki Extensions
List of MediaWiki Extensions
Links

Release status: stable

Implementation Special page
Description To create a random sheet of links for spambots
Author(s) Hidalgo Rionda (Hsilamot Talk)
Version 1.1.39 (03 Dec 2007)
MediaWiki 1.10.0
Download From Author's Site
Parameters $wgLinksTotal

$wgLinksRand $wgLinksRandMin $wgLinksRandMax $wgLinksTldRand $wgLinksTlds $wgLinksTld $wgLinksHTML $wgLinksHTMLs

Example here

[edit] What can this extension do?

Create a random sheet of links for Spam bots with personalizable settings

[edit] Usage

Just link as any other page [[Special:Links]]

[edit] Installation

Just unzip the content and add

require_once( "{$IP}/extensions/Links/Links.php" );


To your 'LocalSettings.php.

[edit] Parameters

$wgLinksTotal = 1024;

The total links that the extension will generate

$wgLinksRand = true;

Should the number of Characters on URL be Random? if not $wgLinksRandMin is deprecated and the number of characters in the url is defined by wgLinksRandMax

$wgLinksRandMin = 5;

If $wgLinksRand is True then this is the minimum characters in the URL

$wgLinksRandMax = 12;

This is the Maximum characters in the URL, if $wgLinksRand is false this is the Exact number of characters in the URL

$wgLinksTldRand = true;

Should the TLD be Random?

If Yes then $wgLinksTld is deprecated and $wgLinksTlds is the TLD's from wich select the random generated TLD

If No then $wgLinksTlds is deprecated and $wgLinksTld is the TLD for all URL's generated

$wgLinksTlds = array("com", "net", "org", "us", "co.uk", "com.mx", "org.mx",);

Array of TLD's if $wgLinksTldRand is True

$wgLinksTld = "com";

This TLD should be used if $wgLinksTldRand is false

$wgLinksHTML = true;

Should the URL after the / have a Random Page? if no $wgLinksHTMLs is not neccesary

$wgLinksHTMLs = array("index.html", "web.html", "page.html", "index.asp",
 "read.html", "get.asp", "index.php", "get.php", "post.html", "reduce.html",);

If $wgLinksHTML is true then this is the list of the pages that can go after the /

[edit] Changes to LocalSettings.php

require_once( "{$IP}/extensions/Links/Links.php" );

[edit] Code

In Links folder are three files:

Links.php

<?php
if (!defined('MEDIAWIKI')) die();
# Not a valid entry point, skip unless MEDIAWIKI is defined
/**
 * Add random links to bother bots
 */
 
$wgExtensionCredits['specialpage'][] = array(
        'name' => 'Links (1.1.39)',
        'author' => 'Hidalgo Rionda',
        'url' => 'http://www.mediawiki.org/wiki/Extension:Links',
        'description' => 'Simple random links Generator, Those links are for Spam bots.',
);
 
$wgAutoloadClasses['Links'] = dirname(__FILE__) . '/Links_body.php';
$wgSpecialPages['Links'] = 'Links';
$wgExtensionFunctions[] = 'efLoadeaLinks';
 
function efLoadeaLinks() {
        global $wgLang, $wgMessageCache;
        $f= dirname( __FILE__ ) . '/Links.i18n.php';
        include( $f );
        foreach( efLinks() as $lang => $messagess ) {
                if ($wgLang->getCode() == $lang) {
                        $wgMessageCache->addMessages( $messagess );
                }
        }
}
?>

Links.i18n.php

<?php
if (!defined('MEDIAWIKI')) die();
function efLinks() {
        $messages = array(
                'en' => array(
                        'links' => 'Links',
                        'links-welcome' => "Welcome, next a series of random [[Special:Links|Links]].\r\n\r\nIf you're human don't try to access these [[Special:Links|Links]], They're made for the spam bots that search [[Special:Links|Links]].\r\n\r\nVisit our friends!:",
                        'links-goodbye' => "Thank you",
                        'links-title' => "Friend Links",
                        'links-startnow' => "Hope you enjoy",
                ),
                'es' => array(
                        'links' => 'Vinculos',
                        'links-welcome' => "Bienvenido, a continuaci&oacute;n una serie [[Special:Links|v&iacute;nculos]] al azar.\r\n\r\nSi eres humano no intentes acceder a las siguientes [[Special:Links|ligas]], Estan hechas para robots que buscan [[Special:Links|p&aacute;ginas]] para SPAM.\r\n\r\nVisita a nuestros amigos:",
                        'links-goodbye' => "Gracias",
                        'links-title' => "Vinculos de Amigos",
                        'links-startnow' => "Espero te gusten los vinculos",
                ),
        );
        return $messages;
}
?>

Links_body.php

<?php
if (!defined('MEDIAWIKI')) die();
class Links extends SpecialPage {
        function __construct() {
                SpecialPage::SpecialPage("Links", '', true);
        }
        function execute( $par ) {
                global $wgRequest, $wgOut, $wgLinksTotal, $wgLinksRand, $wgLinksRandMin, $wgLinksRandMax, $wgLinksTldRand, $wgLinksTlds, $wgLinksTld, $wgLinksHTML, $wgLinksHTMLs;
                if (!$wgLinksTotal) { $wgLinksTotal = 1024; }
                if (!$wgLinksRand) { $wgLinksRand = true; }
                if (!$wgLinksRandMin) { $wgLinksRandMin = 5; }
                if (!$wgLinksRandMax) { $wgLinksRandMax = 12; }
                if (!$wgLinksTldRand) { $wgLinksTldRand = true; }
                if (!$wgLinksTlds) { $wgLinksTlds = array("com", "net", "org", "us", "co.uk", "com.mx", "org.mx",); }
                if (!$wgLinksTld) { $wgLinksTld = "com"; }
                if (!$wgLinksHTML) { $wgLinksHTML = true; }
                if (!$wgLinksHTMLs) { $wgLinksHTMLs = array("index.html", "web.html", "page.html", "index.asp", "read.html", "get.asp", "index.php", "get.php", "post.html", "reduce.html",); }
                $fname = "SpecialLinks::execute";
                $this->setHeaders();
                # Do stuff
                $wgOut->addWikiText( wfMsg( 'links-welcome' ) );
                $wgOut->addHTML( wfMsg( 'links-startnow' ) );
                $Actual = 0;
                while ($Actual < $wgLinksTotal) {
                        $urrl = "";
                        if ($wgLinksRand == true) {
                                $Hechos = 0;
                                $PorHacer = rand($wgLinksRandMin,$wgLinksRandMax);
                                while ($Hechos < $PorHacer) {
                                        $urrl .= chr(rand(97,122));
                                        $Hechos = $Hechos + 1;
                                }
                        }
                        else {
                                $Hechos = 0;
                                while ($Hechos < $wgLinksRandMax) {
                                        $urrl .= chr(rand(97,122));
                                        $Hechos = $Hechos + 1;
                                }
                        }
                        if ($wgLinksTldRand == true) {
                                $Totales = 0;
                                foreach( $wgLinksTlds as $currenteado ) {
                                        $Totales = $Totales + 1;
                                        $TLDA[$Totales] = $currenteado;
                                }
                                $TLD = $TLDA[rand(1,$Totales)];
                        }
                        else {
                                $TLF = $wgLinksTld;
                        }
                        if ($wgLinksHTML == true) {
                                $Totales = 0;
                                foreach( $wgLinksHTMLs as $currenteado ) {
                                        $Totales = $Totales + 1;
                                        $TLDA[$Totales] = $currenteado;
                                }
                                $Finalhtml = $TLDA[rand(1,$Totales)];
                        }
                        else {
                                $Finalhtml = "";
                        }
                        $wgOut->addHTML(", <a href=\"http://www.".$urrl.".".$TLD."/".$Finalhtml."\">http://www.".$urrl.".".$TLD."/".$Finalhtml."</a>");
                        $Actual = $Actual + 1;
                }
                $wgOut->addWikiText( wfMsg( 'links-goodbye' ) );
                # Output
                $wgOut->setPagetitle( wfMsg( "links-title" ) );
        }
}
?>

[edit] See also

Also in Mails Version

Personal tools