16 Feb 2008

Ikariam grease monkey scripts

Autologin grease monkey script for Ikariam:

// ==UserScript==
// @name IkariamAutologin2
// @namespace Ikariam
// @include http://ikariam.de/
// ==/UserScript==

var SERVER = "s5.ikariam.de"; //Nur die Zahl verändern s1 = alpha, s2 = beta
var USERNAME = "username"; //Hier deinen Username eintragen
var PASSWORD = "password"; //Hier dein Passwort eintragen


document.getElementById("universe").value = SERVER;
document.getElementById("login").value = USERNAME;
document.getElementById("pwd").value = PASSWORD;

var url = "http://" + document.getElementById("universe").value + "/index.php?action=loginAvatar&function=login";

document.getElementById('loginForm').action = url;
document.getElementById("loginForm").submit();

7 Feb 2008

php5 beauty, reflection api

the php4 way

beside very usefull features like try/catch php5 has many little nifty features. i had to fetch all methods of a class, regardless of visibility. get_class_methods(mixed $class_name) has been introduced in php4 and is only able to get public methods. I needed a way to list protected/private methods of a class (without the need of executing them).

Reflection API
The reflection api (intreduced in php5) is a much more flexible way to find out information about a class, object, methods, properties, etc.

PHP5 Reflection API Documentation

List all methods of a class (public, private, protected, final, static):

<?php
$r = new ReflectionClass('Exception');
print_r($r->getMethods());
?>