Skip to content

Instantly share code, notes, and snippets.

View dantman's full-sized avatar

Daniel Friesen dantman

View GitHub Profile
@dantman
dantman / Scalar.skin.php
Created February 27, 2012 23:58
Scalar skin (Example of a Vector derived skin)
<?php
/**
* Scalar
*
* @file
* @ingroup Skins
*/
if( !defined( 'MEDIAWIKI' ) )
die( -1 );
@dantman
dantman / HOWTOUSE
Created November 19, 2011 06:50
Script to deobfuscate MediaWiki svn USERINFO emails
- Checkout the svn USERINFO folder into a directory.
- Setup this script right next to it and cd to that directory.
((ie: You should have ./USERINFO and ./useremails.rb sitting in front of you))
((Note: Users who don't have an e-mail set are omitted from outputs))
- `ruby useremails.rb` will give you a list of svn users, their name, and e-mail
- `ruby useremails.rb list` will give you that same list but in a comma separated "Name <email>" format
- `ruby useremails.rb obfuscated` will filter the list to only users who have obfuscated their e-mail
- `ruby useremails.rb obfuscated list` will take that filtered list and put it in the "Name <email>" format
@dantman
dantman / lang.php
Created October 22, 2011 23:03
lang.php to parse accept-lang and return it as json for js to fetch and handle
<?php
define('MEDIAWIKI', 1);
require_once dirname( __FILE__ ) . '/languages/Names.php';
require_once dirname( __FILE__ ) . '/includes/json/FormatJson.php';
// Based on http://www.thefutureoftheweb.com/blog/use-accept-language-header
$langs = array();
if ( isset( $_SERVER['HTTP_ACCEPT_LANGUAGE'] ) ) {
// break up string into pieces (languages and q factors)
1 Aggregator
1 Auth_remoteuser
1 Citation
1 Description
1 DisableSpecialPages
1 EnhanceContactForm
1 FootNote
1 FormPreloadPostCache
1 GlobalNotice
1 GoogleDocs4MW
<?php
class SpecialTitleTargeted extends SpecialPage implements SpecialTitleTarget {
function executeWithTarget() {
$this->getOutput()->addHTML( htmlspecialchars(
$this->target()->getPrefixedText() ) );
}
}
PHP Strict standards: Declaration of AB::output() should be compatible with that of A::output() in /tmp/tmp.php on line 18
Strict standards: Declaration of AB::output() should be compatible with that of A::output() in /tmp/tmp.php on line 18
PHP Strict standards: Declaration of BA::output() should be compatible with that of B::output() in /tmp/tmp.php on line 25
Strict standards: Declaration of BA::output() should be compatible with that of B::output() in /tmp/tmp.php on line 25
PHP Strict standards: Declaration of CA::output() should be compatible with that of C::output() in /tmp/tmp.php on line 35
@dantman
dantman / gist:1257471
Created October 2, 2011 13:45
MediaWiki Special Page $par/request primary target names and preference order
<?php
Allmessages lang -> $par (val -> wfGetLangObj)
Allpages $par -> from/to (val -> db:query:title)
Block wpTarget -> $par -> ip -> wpBlockAddress (text -> Block::parseTarget)
BlockList wpTarget -> ip -> $par (val -> Block::parseTarget -> db:query:ipb)
Categories from -> $par (text -> db:query:title:NS_CATEGORY)
Contributions $par -> target (val -> User/db:query:user)
DeletedContributions $par -> target (val -> Title:NS_USER/db:query:user)
EditWatchlist action -> $par (val -> mode) (@todo Scan for other special pages using an execute( $notCalledPar );
Emailuser $par -> wpTarget -> target (val -> User; does some minor user verification)
@dantman
dantman / Links.dfn
Created September 24, 2011 06:32
MediaWiki Vector Dummy Template
/** Implementation of HTML5 input event **/
/*jQuery.support.inputEvent = false;
(function() {
var el = document.createElement("div");
if ("oninput" in el)
jQuery.support.inputEvent = true;
if ( !jQuery.support.inputEvent ) {
el.setAttribute("oninput", "return;");
if ( typeof el.oninput === "function" )
<?php
function starts_with($haystack, $needle) {
return substr($haystack, 0, strlen($needle)) === $needle;
}
$domain = $_SERVER["HTTP_HOST"] ? $_SERVER["HTTP_HOST"] : $_SERVER["SERVER_NAME"];
$base = "http://$domain";
$draft = starts_with($domain, "draft.");