Jump to content

Toolserver:User:Kylu/emptypages.lol

From mediawiki.org

This page was moved from the Toolserver wiki.
Toolserver has been replaced by Toolforge. As such, the instructions here may no longer work, but may still be of historical interest.
Please help by updating examples, links, template links, etc. If a page is still relevant, move it to a normal title and leave a redirect.

Note that the remarks are, for the most part, double-remarked with PHP syntax.
This is purely to make things more readable using the PHP source tag.
For some reason nobody ever made one for LOLCODE, go figure...
OBTW /* first attempt at usable 
        tool written in lolcode
        more information on the language at:
        'http://lolcode.com/'
        omg.
*/ TLDR

BTW //Start with program declaration & such 
HAI
 BTW //pull libraries & file with login data
 I CAN HAS MYSQL?
 I CAN HAS HTMLOUT?
 I CAN HAS '../login.dat'?

 I HAZ A count ITZA VAR
 LOL count IZ 0

 BTW //create the sql connection, make sure to handle errors gracefully.
 I HAZ A sqllink ITZA VAR
 LOL sqllink IZ mysql.connect('enwiki-p.db.ts.wikimedia.org', myusername, mypassword)
  OMGWTF 'Connect failed' GTFO

 BTW //call the function that defines the sql query.
 CAN IT BE setquery TIEM NAO PLS?

 BTW //this performs the actual query...
 I HAZ A sqlresult ITZA TABLE
 LOL sqlresult IZ mysql.query(sqlquery, sqllink)
  OMGWTF 'Query failed' GTFO

 VISIBLE '<html><title>Empty pages on English Wikipedia</title>'
 VISIBLE '<body><table>'

 BTW //call the function that displays results
 CAN IT BE resulttable TIEM NAO PLS?

 VISIBLE '</tr><br>'   
 VISIBLE 'Total results: '
 VISIBLE count
 VISIBLE '</body></html>'
KTHXBYE
BTW //We are finished.

BTW //* * * Functions below * * *

OBTW /* The resulttable function, displays the contents
        of the array containing the results of the SQL function.
        Terribly crappy output, but it is functional.
*/ TLDR

LET ME SHOW YOU MY resulttable THEYZ null
  IM IN UR LOOP
     IZ sqlresult[count] ?
        YARLY
           count IZ count + 1
           VISIBLE '<tr>'
             I HAS count IN UR sqlresult[count] 
               VISIBLE '<td>'
               VISIBLE '<a href="http://en.wikipedia.org/w/index.php?diff=cur&oldid=prev&title='
               VISIBLE sqlresult[count]
               VISIBLE '">'
               VISIBLE sqlresult[count]
               VISIBLE '</a> </td>'
             MOAR
	NOWAI
           KTHX
  IM OUTA UR LOOP
MY resulttable LET ME SHOW YOU THEM

OBTW /* this just defines the query.
        I moved the query to the end for readability.
        stop laughing! I'm serious!
        anywho, hadn't tried nested source tags,
        so we will do this instead. */
TLDR

LET ME SHOW YOU MY setquery THEYZ null
 BTW //this defines the query...
 I HAZ A sqlquery ITZA VAR
 LOL sqlquery IZ '
   SELECT page_title FROM page
   WHERE page_is_redirect = 0
   AND page_namespace = 0
   AND page_len = 0
   ORDER BY page_title;
 '
MY setquery LET ME SHOW YOU THEM
KTHXBYE