forked from Cavemanon/cavepaintings
PSR-2. I'm not a huge fan, but ugly consistency beats no consistency...
This commit is contained in:
@@ -8,60 +8,75 @@
|
||||
* Documentation:
|
||||
*/
|
||||
|
||||
class LiveFeed extends Extension {
|
||||
public function onSetupBuilding(SetupBuildingEvent $event) {
|
||||
$sb = new SetupBlock("Live Feed");
|
||||
$sb->add_text_option("livefeed_host", "IP:port to send events to: ");
|
||||
$event->panel->add_block($sb);
|
||||
}
|
||||
class LiveFeed extends Extension
|
||||
{
|
||||
public function onSetupBuilding(SetupBuildingEvent $event)
|
||||
{
|
||||
$sb = new SetupBlock("Live Feed");
|
||||
$sb->add_text_option("livefeed_host", "IP:port to send events to: ");
|
||||
$event->panel->add_block($sb);
|
||||
}
|
||||
|
||||
public function onUserCreation(UserCreationEvent $event) {
|
||||
$this->msg("New user created: {$event->username}");
|
||||
}
|
||||
public function onUserCreation(UserCreationEvent $event)
|
||||
{
|
||||
$this->msg("New user created: {$event->username}");
|
||||
}
|
||||
|
||||
public function onImageAddition(ImageAdditionEvent $event) {
|
||||
global $user;
|
||||
$this->msg(
|
||||
make_http(make_link("post/view/".$event->image->id))." - ".
|
||||
"new post by ".$user->name
|
||||
);
|
||||
}
|
||||
public function onImageAddition(ImageAdditionEvent $event)
|
||||
{
|
||||
global $user;
|
||||
$this->msg(
|
||||
make_http(make_link("post/view/".$event->image->id))." - ".
|
||||
"new post by ".$user->name
|
||||
);
|
||||
}
|
||||
|
||||
public function onTagSet(TagSetEvent $event) {
|
||||
$this->msg(
|
||||
make_http(make_link("post/view/".$event->image->id))." - ".
|
||||
"tags set to: ".Tag::implode($event->tags)
|
||||
);
|
||||
}
|
||||
public function onTagSet(TagSetEvent $event)
|
||||
{
|
||||
$this->msg(
|
||||
make_http(make_link("post/view/".$event->image->id))." - ".
|
||||
"tags set to: ".Tag::implode($event->tags)
|
||||
);
|
||||
}
|
||||
|
||||
public function onCommentPosting(CommentPostingEvent $event) {
|
||||
global $user;
|
||||
$this->msg(
|
||||
make_http(make_link("post/view/".$event->image_id))." - ".
|
||||
$user->name . ": " . str_replace("\n", " ", $event->comment)
|
||||
);
|
||||
}
|
||||
public function onCommentPosting(CommentPostingEvent $event)
|
||||
{
|
||||
global $user;
|
||||
$this->msg(
|
||||
make_http(make_link("post/view/".$event->image_id))." - ".
|
||||
$user->name . ": " . str_replace("\n", " ", $event->comment)
|
||||
);
|
||||
}
|
||||
|
||||
public function onImageInfoSet(ImageInfoSetEvent $event) {
|
||||
# $this->msg("Image info set");
|
||||
}
|
||||
public function onImageInfoSet(ImageInfoSetEvent $event)
|
||||
{
|
||||
# $this->msg("Image info set");
|
||||
}
|
||||
|
||||
public function get_priority(): int {return 99;}
|
||||
public function get_priority(): int
|
||||
{
|
||||
return 99;
|
||||
}
|
||||
|
||||
private function msg(string $data) {
|
||||
global $config;
|
||||
private function msg(string $data)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$host = $config->get_string("livefeed_host", "127.0.0.1:25252");
|
||||
$host = $config->get_string("livefeed_host", "127.0.0.1:25252");
|
||||
|
||||
if(!$host) { return; }
|
||||
if (!$host) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$parts = explode(":", $host);
|
||||
$parts = explode(":", $host);
|
||||
$host = $parts[0];
|
||||
$port = $parts[1];
|
||||
$fp = fsockopen("udp://$host", $port, $errno, $errstr);
|
||||
if (! $fp) { return; }
|
||||
fwrite($fp, "$data\n");
|
||||
if (! $fp) {
|
||||
return;
|
||||
}
|
||||
fwrite($fp, "$data\n");
|
||||
fclose($fp);
|
||||
} catch (Exception $e) {
|
||||
/* logging errors shouldn't break everything */
|
||||
|
Reference in New Issue
Block a user