Initial commit
This commit is contained in:
commit
43ad32700c
7085 changed files with 447606 additions and 0 deletions
196
forumplugins/chatusers.php
Normal file
196
forumplugins/chatusers.php
Normal file
|
@ -0,0 +1,196 @@
|
|||
<?php
|
||||
/**
|
||||
* MyBB 1.4
|
||||
* Copyright © 2008 MyBB Group, All Rights Reserved
|
||||
*
|
||||
* Website: http://www.mybboard.net
|
||||
* License: http://www.mybboard.net/about/license
|
||||
*
|
||||
* $Id: hello.php 4304 2009-01-02 01:11:56Z chris $
|
||||
*/
|
||||
|
||||
// Disallow direct access to this file for security reasons
|
||||
if(!defined("IN_MYBB"))
|
||||
{
|
||||
die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
|
||||
}
|
||||
|
||||
$plugins->add_hook("global_start", 'users');
|
||||
//include "cache.class.php";
|
||||
function chatusers_info()
|
||||
{
|
||||
/**
|
||||
* Array of information about the plugin.
|
||||
* name: The name of the plugin
|
||||
* description: Description of what the plugin does
|
||||
* website: The website the plugin is maintained at (Optional)
|
||||
* author: The name of the author of the plugin
|
||||
* authorsite: The URL to the website of the author (Optional)
|
||||
* version: The version number of the plugin
|
||||
* guid: Unique ID issued by the MyBB Mods site for version checking
|
||||
* compatibility: A CSV list of MyBB versions supported. Ex, "121,123", "12*". Wildcards supported.
|
||||
*/
|
||||
return array(
|
||||
"name" => "Chatusers",
|
||||
"description" => "Syncs the Site Database with the forum",
|
||||
"website" => "http://austriachat.net",
|
||||
"author" => "genuineparts",
|
||||
"authorsite" => "http://austriachat.net",
|
||||
"version" => "1.2",
|
||||
"guid" => "",
|
||||
"compatibility" => "*"
|
||||
);
|
||||
}
|
||||
function users()
|
||||
{
|
||||
global $chatusers;
|
||||
$data=chat_online();
|
||||
if ($data["chat_offline"]===true){
|
||||
$chatusers="offline";
|
||||
return;
|
||||
}
|
||||
// Read data and close
|
||||
$chatusers=$data["usercount"];
|
||||
}
|
||||
|
||||
function get_user_list() {
|
||||
global $config;
|
||||
global $config, $ccache;
|
||||
//$hidden=array('Moon','Exil','Adminhouse','Modarea');
|
||||
// Open URL to userlist
|
||||
// erzeuge einen neuen cURL-Handle
|
||||
$ch = curl_init();
|
||||
|
||||
// setze die URL und andere Optionen
|
||||
curl_setopt($ch, CURLOPT_URL, "https://chatsrv.austriachat.net/info");
|
||||
curl_setopt($ch, CURLOPT_HEADER, false);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 3);
|
||||
// führe die Aktion aus und gebe die Daten an den Browser weiter
|
||||
$fh=curl_exec($ch);
|
||||
|
||||
// schließe den cURL-Handle und gebe die Systemresourcen frei
|
||||
curl_close($ch);
|
||||
|
||||
if(!$fh){
|
||||
return false;
|
||||
}
|
||||
$content = trim($fh);
|
||||
$content = explode("\n", $content);
|
||||
|
||||
// Create userlist array
|
||||
// Format of array:
|
||||
// $userlist[$room_name]['s'] = $room_state
|
||||
// $userlist[$room_name]['u'][$nick] = $color
|
||||
$userlist = array();
|
||||
foreach($content as $line) {
|
||||
$data = explode("|", $line);
|
||||
|
||||
list($room_name, $room_state) = explode(",", $data[0]);
|
||||
$userlist[$room_name]['s'] = $room_state;
|
||||
$userlist[$room_name]['u'] = array();
|
||||
array_splice($data, 0, 1);
|
||||
foreach($data as $user) {
|
||||
list($nick, $color) = explode(",", $user);
|
||||
$userlist[$room_name]['u'][$nick] = $color;
|
||||
}
|
||||
}
|
||||
|
||||
// Return userlist
|
||||
return $userlist;
|
||||
}
|
||||
function chat_online(){
|
||||
$online=get_user_list();
|
||||
|
||||
if($online){
|
||||
$rooms=array_keys($online);
|
||||
$i=0;
|
||||
$data["usercount"]=0;
|
||||
|
||||
if(!isset($online[""])){
|
||||
foreach($rooms as $room){
|
||||
if($online[$room]["s"]=="locked"){
|
||||
$data[$i]["room"]=$room . " <span style=\"color:red;\">[abgeschlossen]</span>";
|
||||
}else{
|
||||
$data[$i]["room"]=$room . " <span style=\"color:green;\">[offen]</span>";
|
||||
}
|
||||
|
||||
$users=array_keys($online[$room]["u"]);
|
||||
foreach($users as $user){
|
||||
if($data[$i]["users"]){
|
||||
$data[$i]["users"].=', ';
|
||||
}
|
||||
|
||||
$data["usercount"]++;
|
||||
$data[$i]["users"].='<a href="https://austriachat.net/my/'.$user.'" target="_blank"><span style="color:#'.$online[$room]["u"][$user].'">'.$user.'</span></a>';
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}else{
|
||||
$data["chat_offline"]=true;
|
||||
$data["usercount"]="0";
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* ADDITIONAL PLUGIN INSTALL/UNINSTALL ROUTINES
|
||||
*
|
||||
* _install():
|
||||
* Called whenever a plugin is installed by clicking the "Install" button in the plugin manager.
|
||||
* If no install routine exists, the install button is not shown and it assumed any work will be
|
||||
* performed in the _activate() routine.
|
||||
*
|
||||
* function hello_install()
|
||||
* {
|
||||
* }
|
||||
*
|
||||
* _is_installed():
|
||||
* Called on the plugin management page to establish if a plugin is already installed or not.
|
||||
* This should return TRUE if the plugin is installed (by checking tables, fields etc) or FALSE
|
||||
* if the plugin is not installed.
|
||||
*
|
||||
* function hello_is_installed()
|
||||
* {
|
||||
* global $db;
|
||||
* if($db->table_exists("hello_world"))
|
||||
* {
|
||||
* return true;
|
||||
* }
|
||||
* return false;
|
||||
* }
|
||||
*
|
||||
* _uninstall():
|
||||
* Called whenever a plugin is to be uninstalled. This should remove ALL traces of the plugin
|
||||
* from the installation (tables etc). If it does not exist, uninstall button is not shown.
|
||||
*
|
||||
* function hello_uninstall()
|
||||
* {
|
||||
* }
|
||||
*
|
||||
* _activate():
|
||||
* Called whenever a plugin is activated via the Admin CP. This should essentially make a plugin
|
||||
* "visible" by adding templates/template changes, language changes etc.
|
||||
*
|
||||
* function hello_activate()
|
||||
* {
|
||||
* }
|
||||
*
|
||||
* _deactivate():
|
||||
* Called whenever a plugin is deactivated. This should essentially "hide" the plugin from view
|
||||
* by removing templates/template changes etc. It should not, however, remove any information
|
||||
* such as tables, fields etc - that should be handled by an _uninstall routine. When a plugin is
|
||||
* uninstalled, this routine will also be called before _uninstall() if the plugin is active.
|
||||
*
|
||||
* function hello_deactivate()
|
||||
* {
|
||||
* }
|
||||
*/
|
||||
|
||||
|
||||
?>
|
Loading…
Add table
Add a link
Reference in a new issue