Archive for February, 2005
I wrote a little patch for current MediaWiki CVS which remembers the position of the scrollbar of the textarea when previewing content.
Since I wrote quite a few pages in our local MediaWiki based Intranet, I stumbled over one thing which really annoyed me: when previewing pages, I had to search where I was last time in the textarea. Although you can break down things with editing only specific sections, I always dealt with many content inside the textarea. This patch aims to enhance the useability using javascript to at least remember the position of the scrollbar when the preview button is hit. Read the bug report for how it works, its limits and which browser do not support it.
Bug report with patch: http://bugzilla.wikimedia.org/show_bug.cgi?id=1499
February 23rd, 2005
I wrote a small external authentication script for use with MediaWiki. It should be prepended in front of every PHP script ran with MediaWiki. This can easily done with auto_prepend_file.
New users cannot register themselves this way, however for my environment this was needed. I’m using WikiMedia for an intranet and it should provide external access for existing users, 401 authenticated against the MediaWiki user database and automatic login. In the session the state, whether the user has successfully authenticated, is recorded and kept. If he isn’t, he’s challenged with a 401. The nice thing is that, upon successful first time login, the script emulates the login process by carefully setting the environment variables which are usually set when a real login is done. I initially wanted to use the native MediaWiki methods, but the abstraction was not practically useable for me.
Source
February 16th, 2005
The updated ChelloStatus class encapsulates the actions better and this time I’ll only server a phps link, no crap code pasting here: ChelloStatus class.
Achja, requires PHP5.
February 14th, 2005
With this PHP script you can easily check your bandwith status if you’re a customer of chello. This is most likely only useable from within austria/vienna.
Run it from the console and it returns ‘green’, ‘yellow’, ‘red’ or ‘unknown’. The first three map to the traffic light image. If the state can’t be detected, ‘unknown’ is returned.
Note:
- Use at your own risk
- Requires the PEAR HTTP_Client package (pear install -o HTTP_Client)
- Has a weak detection mechansim (regular expression search for the traffic light image)
- Will break as soon as they change their site in any area this script relies on
- Usage: create a new ChelloStatus instance and call getStatus() with the proper authentication information
- Uh .. WordPress doesn’t nicely support code fragments …
[php]
require_once 'HTTP/Client.php';
class ChelloStatus {
const FORM_USERNAME_NAME = 'username';
const FORM_PASSWORD_NAME = 'password';
const FORM_SUBMIT_NAME = 'submit';
const FORM_SUBMIT_VALUE = 'absenden';
const URL_LOGIN = 'http://ecc.chello.at/cgi-bin/uwfe/casc/casc_start.cgi';
const URL_ACCOUNT = 'http://ecc.chello.at/cgi-bin/uwfe/odv/xacct.cgi?no=0&new=1';
private $oHttpClient;
private $sUsername;
private $sPassword;
function __construct() {
$this->oHttpClient = new HTTP_Client;
}
public function getStatus($sUsername, $sPassword) {
$this->sUsername = $sUsername;
$this->sPassword = $sPassword;
return $this->getChelloStatus();
}
private function getChelloStatus() {
$this->oHttpClient->post(
ChelloStatus::URL_LOGIN,
array(
ChelloStatus::FORM_USERNAME_NAME => $this->sUsername,
ChelloStatus::FORM_PASSWORD_NAME => $this->sPassword,
ChelloStatus::FORM_SUBMIT_NAME => ChelloStatus::FORM_SUBMIT_VALUE
)
);
$this->oHttpClient->get(ChelloStatus::URL_ACCOUNT);
$aLastResponses = array_pop($this->oHttpClient->_responses);
return $this->filterStatus($aLastResponses['body']);
}
public function filterStatus($sHhtml) {
$aChelloStatus = array(
'images/xacct/green.gif' => 'green',
'images/xacct/yellow.gif' => 'yellow',
'images/xacct/red.gif' => 'red',
);
$sStateFound = "unknown";
foreach ($aChelloStatus as $sPreg => $sState) {
if (preg_match(";$sPreg;", $sHhtml)) {
$sStateFound = $sState;
break;
}
}
return $sStateFound;
}
}
?>
[/php]
February 6th, 2005