The PHP code:
<?php
echo 'The PHP code:<br />';
highlight_file(__FILE__);
require '../bootstrap-stubbles.php';
stubClassLoader::load('net::stubbles::events::events',
'org::stubbles::examples::events::Auth',
'org::stubbles::examples::events::BlackList',
'org::stubbles::examples::events::UserLoginLogging'
);
class Bootstrap
{
public static function main()
{
// get an instance of the event dispatcher
$eventDispatcher = stubEventDispatcher::getInstance();
// and configure it with some event listeners
$eventDispatcher->register(new BlackList(), 'onLogin');
$eventDispatcher->register(new UserLoginLogging(), 'onLogin');
// now we simply authenticate users
$auth = new Auth();
$auth->login('mikey', 'secret');
var_dump($auth->isValid());
$auth->login('schst', 'evenmoresecret');
var_dump($auth->isValid());
// display logs
echo '<br /><br />The logfile:<br />';
printf('<b>%s</b></br /><pre>%s</pre>', 'user.log', file_get_contents(stubConfig::getLogPath() . '/user.log'));
}
}
Bootstrap::main();
?>
Warning: error_log(/var/www/schst/examples.stubbles.net/examples/log/user.log) [function.error-log]: failed to open stream: Permission denied in /var/www/schst/examples.stubbles.net/src/main/php/org/stubbles/examples/events/UserLoginLogging.php on line 29
bool(true)
Warning: error_log(/var/www/schst/examples.stubbles.net/examples/log/user.log) [function.error-log]: failed to open stream: Permission denied in /var/www/schst/examples.stubbles.net/src/main/php/org/stubbles/examples/events/BlackList.php on line 31
bool(false)
The logfile:
Warning: file_get_contents(/var/www/schst/examples.stubbles.net/examples/log/user.log) [function.file-get-contents]: failed to open stream: No such file or directory in /var/www/schst/examples.stubbles.net/examples/docroot/events/index.php on line 30
user.log