Skip to content

Instantly share code, notes, and snippets.

@Felk
Created July 10, 2016 02:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Felk/c50e3a20ec511301dc21ed9079cb38d0 to your computer and use it in GitHub Desktop.
Save Felk/c50e3a20ec511301dc21ed9079cb38d0 to your computer and use it in GitHub Desktop.
OCS V0.74 ajax_request_handler
<?php
ob_start();
date_default_timezone_set('Europe/Berlin');
header('content-type: text/html; charset=UTF-8');
error_reporting(E_ALL ^ E_NOTICE);
session_start();
if (get_magic_quotes_gpc()) {
function stripslashes_deep($value) {
$value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);
return $value;
}
$_POST = array_map('stripslashes_deep', $_POST);
$_GET = array_map('stripslashes_deep', $_GET);
$_COOKIE = array_map('stripslashes_deep', $_COOKIE);
$_REQUEST = array_map('stripslashes_deep', $_REQUEST);
}
require_once("config.php");
//if (empty($_REQUEST['input'])) exit;
if (!isset($_POST['input'])) $_POST['input'] = '';
$in = $_POST['input'];
@$mode = $_POST['mode'];
@$user_id = $_SESSION[PREFIX.'user_id'];
if (empty($user_id)) {
exit;
}
$cflags = $_SESSION[PREFIX.'cflags'];
if (!isset($cflags)) $cflags = array('users' => -1, 'channels' => -1, 'partymembers' => -1);
foreach($cflags as $key => $value) {
$cflags[$key]++;
}
require_once("connect.php");
require_once("functions.php");
require_once("invitation_manager.class.php");
require_once("config2.php");
$data = query("SELECT * FROM ".PREFIX."users WHERE id = ".$user_id." LIMIT 1");
if ($data->num_rows == 0) {
exit;
} else {
$data = $data->fetch_assoc();
}
$muted = isMuted($user_id);
$mute_messages = array("Pshht!", "Psst! H&ouml;rst du das? Ruhe.", "Sei ruhig, Sh4d0w!", "Ruhe! Wichtige Leute unterhalten sich hier.", "Du hast jetzt Sendepause!", "Shut. The Fuck. UP!", "Sei ruhig!", "Du befindest dich auf dem Stillen Stuhl, rede nicht.", "Versuch es erst garnicht!", "Nein!", "Schweig!", "Hey, mit dir redet keiner!", "Das OCS verweigert dir den Dienst.", "Hast du keinen Friseur, dem Du den Quatsch erz&auml;hlen kannst?", "Das passt da nicht hin!", "Beantworte erst die 3 Fragen! 1. Was ist deine Lieblingsfarbe?", "Das m&ouml;chte doch keiner lesen...", "Warte... warte... nein.", "Computer sagt nein.", "H&ouml;r auf.", "H&ouml;r mal, wer da nervt.", "Probier es sp&auml;ter nochmal!", "Sie gehen den anderen auf den Sack.", "Halt stop!", "Sprich mit der Hand.", "Geh doch einfach offline.", "Stirb.", "Du kannst jetzt nicht reden. Denke w&auml;hrenddessen &uuml;ber dein Verhalten nach.", "Frohe Weihnachten.", "Hast du was gesagt?", "Wie bitte? Die Verbindung ist so schlecht!", "Was? Du bist so leise!", "<span style=\"font-size:12px;\">Nein</span>, <span style=\"font-size:14px;\">nein</span>, <span style=\"font-size:16px;\">nein!</span>", "Niemand kann dich h&ouml;ren.", "Geh schlafen, das Sandm&auml;nnchen lief bereits!", "Wenigstens kannst du noch reden. Ach! Doch nicht.", "Interessant, was du sagst. Naja, doch nicht.", "Wenn du ein Problem hast, schreib es einfach in den Chat.", "Nein!!!", "Neeeeeein!", "Nein.", "Neeeeeeeeeeeeeeeeeeeeeeeeeein!", "Muten, ne super Sache.", "Keine Sorge, gemuted zu sein ist cool!", "Psht! Erwachsene reden.", "Was?", "Erz&auml;hl das einer Parkuhr.", "Sprechen sie nach dem Piepton...", "Hey, diese Spr&uuml;che sind echt toll!", "Du erzeugst nur Datenm&uuml;ll!", "Moment, meine Klosp&uuml;lung erz&auml;hlt gerade etwas spannenderes...");
if (OCS_OFFLINE > 0) {
$die_msg = '';
if (OCS_OFFLINE == 1) $die_msg = "offline";
if (OCS_OFFLINE == 2) $die_msg = "long_offline";
if ($data['level'] < 2) {
echo $die_msg;
ob_end_flush();
exit;
}
}
if ($data['level'] < 0 || is_ip_banned($data['ip'])) {
echo "banned";
ob_end_flush();
$_SESSION = array();
session_destroy();
exit;
}
//if ($data['ip'] != $_SERVER['REMOTE_ADDR']) {
// $_SESSION = array();
// session_destroy();
// die("ip_changed");
//}
$channel_id = $data['last_channel'];
$channel = get_channel();
$channel_rounds = $channel['rounds'];
if ($channel_rounds > 0) {
if ($party = get_current_party_assoc()) {
if ($in_this_party = in_party($user_id,$party['id'])) {
$awaiting_ready = false;
} else {
if ($party['active_mode'] == 'running') {
$awaiting_ready = false;
} else {
if ($party['joining_type'] == 'join') {
$awaiting_ready = true;
} else {
$awaiting_ready = false;
}
}
}
} else {
$awaiting_ready = false;
}
} else {
$awaiting_ready = false;
}
$old_parties = get_old_parties($channel_id);
foreach ($old_parties as $old_party_id) {
$flag = true;
$users = get_party_members($old_party_id);
while ($maybe = $users->fetch_object()) {
$maybe = $maybe->user_id;
$online = true;
$online = query("SELECT UNIX_TIMESTAMP(last_update) FROM ".PREFIX."users WHERE id = $maybe LIMIT 1");
$online = $online->fetch_row();
$online = $online[0];
if ($online > time()-MAX_RESPONSE_LIMIT) $online = true;
else $online = false;
if ($maybe != $party['owner_id'] && $online) {
query("UPDATE ".PREFIX."parties SET owner_id = $maybe WHERE id = $old_party_id LIMIT 1");
system_message('<u>'.gunbi($maybe).'</u> wurde zum neuen Partybesitzer ernannt, da '.gunbi($party['owner_id']).' offline ist.');
$party['owner_id'] = $maybe;
$flag = false;
break;
}
}
if ($flag) cancel_party($old_party_id,'',true);
}
$in_party = in_party();
$awaiting_time = user_awaiting_time();
$current_round = get_current_round();
query("UPDATE ".PREFIX."users Set last_update = CURRENT_TIMESTAMP WHERE id = $user_id");
$von = array('[M_S]','[A_S]','[ALL_S]','[LI_S]','[NC_S]');
$in = str_replace($von, '[IC]', $in);
$in = htmlentities($in, ENT_QUOTES, 'UTF-8');
$in = preg_replace("!(^|[[:space:]])www\.(.*?)([[:space:]]|$)!im"," <a target=\"_blank\" href=\"http://www.$2\">www.$2</a> ",$in);
$in = preg_replace("!(^|[[:space:]])http://(.*?)([[:space:]]|$)!im"," <a target=\"_blank\" href=\"http://$2\">http://$2</a> ",$in);
$in = nl2br($in);
$len = strlen(parse_smileys($in));
// Folgendes wurde dafür für normale Chatnachrichten eingefügt
//if ($len > MAX_CHAT_LENGTH) {
// $in = substr($in,0,MAX_CHAT_LENGTH);
//}
$in_p = explode(" ",$in);
if (!isset($in_p[0])) $in_p[0] = '';
if (!isset($in_p[1])) $in_p[1] = '';
if (!isset($in_p[2])) $in_p[2] = '';
if (!isset($in_p[3])) $in_p[3] = '';
$last_id = array_shift($in_p);
// Autologout nach, standardmäßig, 30 Minuten
if (!isset($_SESSION['last_active'])) $_SESSION['last_active'] = time();
if ($in_p[0] != "POST") if (time() - $_SESSION['last_active'] > AUTO_LOGOUT_TIME) {
echo "logout";
ob_end_flush();
$_SESSION = array();
session_destroy();
exit;
}
/////////////////////////////////////////////
echo $data['namecolor'].'[NC_S]';
echo $mode.'[M_S]';
if ($in_p[0] == "POST") {
$_SESSION['last_active'] = time();
if ( (get_last_post() > time()-MIN_POST_INTERVAL) && $data['level'] <= 1 ) {
system_whisper_message('Flutschutz.');
} else {
if (empty($in_p[2]) && empty($in_p[1])) {
// Flutschutz
} elseif ($in_p[1] == '/namecolor' && !$muted) {
@$color = $in_p[2];
if (empty($color)) {
system_whisper_message('Deine aktuelle Namensfarbe ist '.$data['namecolor']);
} elseif (!preg_match("/^[0-9A-F]+$/i", $color) || strlen($color) != 6) {
system_whisper_message('\''.$color.'\' ist kein g&uuml;ltiger Hexadezimalwert!');
} else {
$r1 = hexdec(substr($color, 0, 2));
$g1 = hexdec(substr($color, 2, 2));
$b1 = hexdec(substr($color, 4, 2));
$r2 = hexdec(substr(BACKGROUND_COLOR_HEX, 0, 2));
$g2 = hexdec(substr(BACKGROUND_COLOR_HEX, 2, 2));
$b2 = hexdec(substr(BACKGROUND_COLOR_HEX, 4, 2));
$r3 = ($r1-$r2)/256;
$g3 = ($g1-$g2)/256;
$b3 = ($b1-$b2)/256;
$difference = abs(sqrt($r3*$r3 + $g3*$g3 + $b3*$b3));
//$difference = abs($r1-$r2)+abs($g1-$g2)+abs($b1-$b2);
$needed = 0.28;
if ($difference < $needed) {
system_whisper_message("Die Farbe #$color &auml;hnelt der Hintergrundfarbe zu sehr! Die Differenz betr&auml;gt ".number_format($difference*100, 2)."%, muss aber mindestens ".($needed*100)."% betragen.");
} else {
query("UPDATE ".PREFIX."users SET namecolor = '$color' WHERE id = $user_id LIMIT 1");
if (strpos($data['username'], "girl") !== false) {
system_message($data['username'].' hat ihre Namensfarbe in <span style="color:#'.$color.';">diese Farbe</span> ge&auml;ndert.');
} else {
system_message($data['username'].' hat seine Namensfarbe in <span style="color:#'.$color.';">diese Farbe</span> ge&auml;ndert.');
}
}
}
} elseif ($in_p[1] == '/unamecolor' && $data['level'] >= 2) {
@$username = $in_p[2];
@$color = $in_p[3];
if (!$userid = guibn($username)) {
system_whisper_message('Der User <u>'.$username.'</u> wurde nicht gefunden.');
} else {
$user = query("SELECT * FROM ".PREFIX."users WHERE id = $userid LIMIT 1");
$user = $user->fetch_assoc();
if (empty($color)) {
system_whisper_message('Die aktuelle Namenfarbe von '.$user['username'].' ist '.$user['namecolor']);
} elseif (!preg_match("/^[0-9A-F]+$/i", $color) || strlen($color) != 6) {
system_whisper_message('\''.$color.'\' ist kein g&uuml;ltiger Hexadezimalwert!');
} else {
$r1 = hexdec(substr($color, 0, 2));
$g1 = hexdec(substr($color, 2, 2));
$b1 = hexdec(substr($color, 4, 2));
$r2 = hexdec(substr(BACKGROUND_COLOR_HEX, 0, 2));
$g2 = hexdec(substr(BACKGROUND_COLOR_HEX, 2, 2));
$b2 = hexdec(substr(BACKGROUND_COLOR_HEX, 4, 2));
$r3 = ($r1-$r2)/256;
$g3 = ($g1-$g2)/256;
$b3 = ($b1-$b2)/256;
$difference = abs(sqrt($r3*$r3 + $g3*$g3 + $b3*$b3));
//$difference = abs($r1-$r2)+abs($g1-$g2)+abs($b1-$b2);
$needed = 0.28;
if ($difference < $needed) {
system_whisper_message("Die Farbe #$color &auml;hnelt der Hintergrundfarbe zu sehr! Die Differenz betr&auml;gt ".number_format($difference*100, 2)."%, muss aber mindestens ".($needed*100)."% betragen.");
} else {
query("UPDATE ".PREFIX."users SET namecolor = '$color' WHERE id = $userid LIMIT 1");
system_message($user['username'].' hat seine Namensfarbe in <span style="color:#'.$color.';">diese Farbe</span> ge&auml;ndert.');
}
}
}
} elseif ($in_p[1] == '/join') {
if ($awaiting_ready == true) {
join_party();
system_message('<u>'.$data['username'].'</u> nimmt an der Party teil!');
$cflags['partymembers'] = -1;
} else {
system_whisper_message('Du kannst hier nicht an einer Party teilnehmen!');
}
} elseif ($in_p[1] == '/new_party' && !$muted) {
$type = $in_p[2];
if ($channel_rounds > 0) {
if (!$in_party) {
if (!get_current_party_assoc()) {
$cflags['partymembers'] = -1;
if ($type != 'join' && $type != 'invite') $type = 'join';
$last_p_id = create_new_party($type);
join_party($last_p_id);
$in_party = true;
$partyname = get_party_name($type);
$message = '<b><u>'.$data['username'].'</u> erstellt eine '.$partyname.'!</b><br />'.$data['username'].' kann sie mit dem Konsolenbefehl "/go", gefolgt von dem Puzzletyp (z.B. 3x3 oder pyraminx), starten.<br />';
if ($type == 'join') {
$message .= 'Du kannst an dieser Party teilnehmen, indem du auf "Teilnehmen" klickst.';
} else if ($type == 'invite') {
$cflags['users'] = -1;
$message .= $data['username'].' kann Partymitglieder mit dem Konsolenbefehl /invite, gefolgt von einem oder mehreren Usernamen, der Party hinzufügen.';
} else {
$message .= 'Eventuell kannst du an dieser Party teilnehmen, indem du auf "Teilnehmen" klickst.';
}
system_message($message);
} else {
system_whisper_message('In diesem Channel ist bereits eine Party am Laufen.');
}
} else {
$pid = query("SELECT party_id FROM ".PREFIX."party_members WHERE user_id = $user_id ORDER BY id DESC LIMIT 1");
$pid = $pid->fetch_row();
$pid = $pid[0];
$cid = query("SELECT channel_id FROM ".PREFIX."parties WHERE id = $pid LIMIT 1");
$cid = $cid->fetch_row();
$cid = $cid[0];
if ($cid == $channel_id) {
system_whisper_message('Du hast bereits eine Party am Laufen!');
} else {
system_whisper_message('Du bist in einem anderen Channel bereits in einer anderen Party! <a href="#" onclick="post(\'/enter '.$cid.'\')">&raquo; In den Channel</a>');
}
}
} else {
system_whisper_message('In diesem Channel kann keine Party gestartet werden!');
}
} elseif ($in_p[1] == '/time') {
if ($awaiting_time) {
$time = $in_p[2];
if (substr_count($time, ',') == 1) $time = str_replace(',', '.', $time);
if (!is_numeric($time)) {
system_whisper_message("Bitte geben sie eine Zahl ein!");
} else {
$cflags['last_results'] = -1;
if ($time < 0) {
$type = get_time_type($time);
set_time($time);
system_message($data['username'].': '.$type);
} else {
if (substr_count($time, '.') == 1) $time = (int)round((double)$time*1000);
else $time = (int)$time;
if ($time == 3141 || $time == 3142) system_message($data['username']." hat den W&uuml;rfel in &pi; Sekunden gel&ouml;st.");
//$time = round($time/10);
set_time($time);
system_message($data['username'].': '.ms_to_str($time));
}
}
} else {
system_whisper_message('In diesem Channel wird von dir momentan keine Zeit erwartet!');
}
} elseif ($in_p[1] == '/changetime') {
if ($in_party && $party) {
$entry = query("SELECT pt.* FROM ".PREFIX."party_times as pt, ".PREFIX."parties as p, ".PREFIX."party_members as pm WHERE pt.time != 0 AND pt.user_id = ".$data['id']." AND pt.party_id = p.id AND p.id = ".$party['id']." AND p.channel_id = $channel_id AND pm.party_id = p.id AND pm.user_id = ".$data['id']." AND p.active_mode = 'running' ORDER BY pt.id DESC LIMIT 1");
if ($entry->num_rows == 1) {
$time = $in_p[2];
if (substr_count($time, ',') == 1) $time = str_replace(',', '.', $time);
if (!is_numeric($time)) {
system_whisper_message("Gib sie eine Zahl ein!");
} else {
$cflags['last_results'] = -1;
$entry = $entry->fetch_assoc();
$old_time = $entry['time'];
if ($old_time < 0) {
$old_time_str = get_time_type($old_time);
} else {
$old_time_str = ms_to_str($old_time);
}
if ($time < 0) {
$type = get_time_type($time);
//set_time($time);
system_message($data['username'].': '.$type.' (Korrektur von '.$old_time_str.')');
} else {
if (substr_count($time, '.') == 1) $time = (int)round((double)$time*1000);
else $time = (int)$time;
//set_time($time);
system_message($data['username'].': '.ms_to_str($time).' (Korrektur von '.$old_time_str.')');
}
query("UPDATE ".PREFIX."party_times SET time = $time WHERE id = ".$entry['id']);
}
} else {
system_whisper_message('Die letzte Zeit kann oder darf nicht ver&auml;ndert werden.');
}
} else {
system_whisper_message('Du bist in keiner Party oder.');
}
} elseif ($in_p[1] == '/enter') {
$id = (int)$in_p[2];
@$pw = sha1($in_p[3]);
if ($new_channel = get_channel($id)) {
if ($new_channel['password'] == $pw || $new_channel['password'] == '') {
if ($new_channel['rounds'] == 0) $avg_type = 'nichts';
else {
switch($new_channel['type']) {
case 'average':
$avg_type = 'Average '.$new_channel['rated_rounds'].'/'.$new_channel['rounds'].'';
break;
case 'mean':
$avg_type = 'Mean of '.$new_channel['rounds'].'';
break;
case 'best':
$avg_type = 'Best of '.$new_channel['rounds'].'';
break;
default:
$avg_type = 'nichts';
}
}
$cflags['partymembers'] = -1;
$cflags['users'] = -1;
$cflags['channels'] = -1;
$entered = '<u>'.$data['username'].'</u> hat den Channel <u>betreten</u>.';
$leaved = '<u>'.$data['username'].'</u> hat den Channel <u>verlassen</u>.';
$text = '<span style="color:green;"><b>Du hast in den Channel <u>'.$new_channel['name'].'</u> gewechselt! Hier findet '.$avg_type.' statt!</b>';
if (!empty($new_channel['description'])) $text .= ' <b>Channelbeschreibung:</b><br />'.$new_channel['description'];
if (!empty($new_channel['owner_id'])) $text .= '<br />Channel-ID: '.$new_channel['id'].' - Channel-Besitzer: '.gunbi($new_channel['owner_id']);
$text .= '</span>';
system_message($entered,$id);
system_message($leaved,$channel_id);
system_whisper_message($text);
query("UPDATE ".PREFIX."users Set last_channel = $id WHERE id = $user_id");
$channel_id = $id;
} else {
system_whisper_message('Das Passwort stimmt nicht!');
}
} else {
system_whisper_message('Ein Channel mit der ID '.$id.' existiert nicht!');
}
} elseif ($in_p[1] == '/whisper' && !$muted) {
@$uid = guibn($in_p[2]);
if ($id = $uid) {
array_shift($in_p);
array_shift($in_p);
array_shift($in_p);
$text = implode(' ',$in_p);
whisper_message($text,$id);
} else {
$message = "Der User <u>".$in_p[2]."</u> existiert nicht!";
system_whisper_message($message);
}
} elseif ($in_p[1] == '/status' && !$muted) {
array_shift($in_p);
array_shift($in_p);
$status = implode(' ',$in_p);
$raw_status = html_entity_decode($status, ENT_QUOTES, 'UTF-8');
if (!empty($status)) {
//if (!preg_match("/^[-0-9A-Z_@^%()\[\][:space:]:;=äöüÄÖÜß!?,+.&\s]+$/i", $status)) {
// system_whisper_message('Es sind nur folgende Zeichen erlaubt: 0-9 A-Z Ä Ö Ü ß _ @ ^ % ( ) [ ] : ; = ! ? . , + - und Leerzeichen');
if (false) {} else {
//if ((substr_count($status,'&auml;') + substr_count($status,'&Auml;') +
// substr_count($status,'&ouml;') + substr_count($status,'&Ouml;') +
// substr_count($status,'&uuml;') + substr_count($status,'&Uuml;') + substr_count($status,'&szlig;')) > 4) {
// system_whisper_message('Zu viele Umlaute oder &szlig;, maximal 4 (aus speichertechnischen Gr&uuml;nden).');
//} else {
if (strlen($status) > MAX_STATUS_LENGTH) {
system_whisper_message('Der Status darf maximal '.MAX_STATUS_LENGTH.' Zeichen lang sein!');
} else {
$cflags['users'] = -1;
query("UPDATE ".PREFIX."users Set status = '".escape_string($status)."' WHERE id = $user_id LIMIT 1");
system_message('Der Status von '.$data['username'].' wurde in \''.escape_string($status).'\' ge&auml;ndert.');
}
//}
}
} else {
$cflags['users'] = -1;
query("UPDATE ".PREFIX."users Set status = '' WHERE id = $user_id LIMIT 1");
system_message('Der Status von '.$data['username'].' wurde entfernt.');
}
} elseif ($in_p[1] == '/me' && !$muted) {
array_shift($in_p);
array_shift($in_p);
$text = implode(' ',$in_p);
me_message($text);
} elseif ($in_p[1] == '/cancel') {
array_shift($in_p);
array_shift($in_p);
$text = implode(' ',$in_p);
if ($party) {
if ($party['owner_id']==$user_id || $data['level'] >= 2) {
$cflags['partymembers'] = -1;
$cflags['users'] = -1;
cancel_party($party['id'],$text);
} else {
system_whisper_message('Du darfst nur eigene Partys abbrechen!');
}
} else {
system_whisper_message('Hier ist keine Party!');
}
} elseif ($in_p[1] == '/leave') {
if (empty($in_p[2])) {
if ($in_party) {
if ($party['owner_id'] != $user_id) {
if (leave_party()) {
$cflags['partymembers'] = -1;
$cflags['users'] = -1;
system_message('<u>'.$data['username'].'</u> hat die Party verlassen!');
} else {
system_whisper_message('Du kannst momentan keine Party verlassen.');
}
} else {
system_whisper_message('Du kannst aus keiner Party aussteigen, die dir geh&ouml;rt! Wenn du die Party abbrechen willst, kannst du /cancel verwenden.');
}
} else {
system_whisper_message('Du bist (hier) in keiner Party!');
}
} else {
$usr = $in_p[2];
if ($usrid = guibn($usr)) {
if ($party) {
if ($party['owner_id'] == $user_id || $data['level'] >= 2) {
if ($usrid != $user_id) {
if ($party['owner_id'] != $usrid) {
if (leave_party($usrid)) {
$cflags['partymembers'] = -1;
$cflags['users'] = -1;
system_message($usr.' wurde aus der Party gekickt.');
} else {
system_whisper_message('Der User '.$usr.' ist nicht in dieser Party!');
}
} else {
system_whisper_message('Du kannst nicht den Partybesitzer kicken!');
}
} else {
system_whisper_message('Du kannst dich nicht selbst kicken!');
}
} else {
system_whisper_message('Du darfst nur Leute aus einer eigenen Party kicken!');
}
} else {
system_whisper_message('Hier ist keine Party!');
}
} else {
system_whisper_message('Der User '.$usr.' existiert nicht!');
}
}
} elseif ($in_p[1] == '/go') {
if ($in_party) {
if($party['owner_id'] == $user_id) {
if ($current_round == 0) {
array_shift($in_p);
array_shift($in_p);
$type = implode(' ',$in_p);
if (strlen($type) < 40) {
set_party_type($type);
next_round();
} else {
system_whisper_message("Der Scramblename darf maximal 40 Zeichen lang sein.");
}
} else {
system_whisper_message('Die Party ist bereits gestartet!');
}
} else {
system_whisper_message('Die Party geh&ouml;rt dir nicht!');
}
} else {
system_whisper_message('Du bist in keiner Party!');
}
} elseif ($in_p[1] == '/blakeineahnung') {
system_whisper_message("Mein Lieber Freund, unter der Chateingabebox findest du eine Befehls-Liste!");
} elseif ($in_p[1] == '/invite') {
array_shift($in_p);
array_shift($in_p);
$users = $in_p;
if ($party['owner_id'] == $user_id && $party['joining_type'] == 'invite') {
foreach ($users as $user) {
if ($userid = guibn($user)) {
$user_data = query("SELECT last_channel,UNIX_TIMESTAMP(last_update) as last_update FROM ".PREFIX."users WHERE id = ".$userid." LIMIT 1");
$user_data = $user_data->fetch_assoc();
if ($user_data['last_channel'] == $party['channel_id'] && $user_data['last_update'] > time()-MAX_RESPONSE_LIMIT) {
if (!in_party($userid)) {
if ($party['active_mode'] == 'waiting') {
$cflags['partymembers'] = -1;
$cflags['users'] = -1;
join_party(false, $userid);
system_message('<u>'.$user.'</u> wurde in die Party eingeladen!');
} else {
system_whisper_message('Du kannst niemanden mehr in die Party einladen, denn die Party hat bereits begonnen!');
}
} else {
system_whisper_message('Der User '.$user.' befindet sich bereits in der Party.');
}
} else {
system_whisper_message('Der User '.$user.' befindet sich nicht in diesem Channel und/oder ist offline.');
}
} else {
system_whisper_message('Der User '.$user.' existiert nicht.');
}
}
} else {
system_whisper_message('Dir geh&ouml;rt hier keine Einladungsparty.');
}
} elseif ($in_p[1] == '/loginto' && $data['level'] >= 6) {
array_shift($in_p);
array_shift($in_p);
$text = implode(' ',$in_p);
if (!is_integer($text)) {
$id = guibn($text);
if ($id === false) {
system_whisper_message("Dieser Account existiert nicht");
} else {
system_message($data['username'].' hat sich in den Account von '.$text.' eingeloggt.');
$_SESSION[PREFIX.'user_id'] = $id;
query("UPDATE ".PREFIX."users Set ip = '".$_SERVER['REMOTE_ADDR']."' WHERE id = $id LIMIT 1");
}
} else {
$exists = query("SELECT COUNT(*) FROM ".PREFIX."users WHERE id = $text LIMIT 1");
$exists = $exists->fetch_row();
$exists = $exists[0];
if ($exists == 1) {
system_message($data['username'].' hat sich in den Account von '.gunbi($text).' eingeloggt.');
$_SESSION[PREFIX.'user_id'] = $text;
} else {
system_whisper_message("Dieser Account existiert nicht");
}
}
} elseif ($in_p[1] == '/shout' && $data['level'] >= 2) {
array_shift($in_p);
array_shift($in_p);
$text = implode(' ',$in_p);
shout_message($text);
} elseif ($in_p[1] == '/channelshout' && $data['level'] >= 2) {
array_shift($in_p);
array_shift($in_p);
$text = implode(' ',$in_p);
channelshout_message($text);
} elseif ($in_p[1] == '/setpw' && ($data['level'] >= 3 || $in_p[2] == $data['username'])) {
$username = $in_p[2];
$password1 = $in_p[3];
$password2 = $in_p[4];
$user = $db->query("SELECT * FROM ".PREFIX."users WHERE username = '".$db->real_escape_string($username)."' LIMIT 1");
if ($user->num_rows == 1) {
$user = $user->fetch_assoc();
if ($user['level'] < $data['level'] || $user['id'] == $data['id']) {
if ($password1 == $password2) {
$salt = ocsgenerate_salt(8);
$password = sha1(sha1($salt).sha1($password1));
$db->query("UPDATE ".PREFIX."users SET password = '".$password."', salt = '".$salt."' WHERE id = ".$user['id']);
system_whisper_message('Das Passwort f&uuml;r <u>'.$username.'</u> wurde erfolgreich ge&auml;ndert!');
} else {
system_whisper_message('Das Passwort wurde nicht korrekt 2x gleich eingegeben.');
}
} else {
system_whisper_message('Der User hat einen gleichen oder h&ouml;heren Rang als du!');
}
} else {
system_whisper_message('User nicht gefunden.');
}
} elseif ($in_p[1] == '/bann' && $data['level'] >= 2) {
array_shift($in_p);
array_shift($in_p);
$text = implode(' ',$in_p);
$text_p = explode(" ",$text);
$name = $text_p[0];
array_shift($in_p);
$reason = implode(' ',$in_p);
if ($usrid = guibn($name)) {
if ($usrid != $user_id) {
$udata = query("SELECT * FROM ".PREFIX."users WHERE id = ".$usrid." LIMIT 1");
$udata = $udata->fetch_assoc();
if ($udata['level'] < $data['level']) {
if (empty($reason)) {
system_message('<b>'.$name.' wurde von '.$data['username'].' grundlos gebannt.</b>');
} else {
system_message('<b>'.$name.' wurde von '.$data['username'].' mit folgender Begr&uuml;ndung gebannt: '.$reason.'</b>');
}
set_level($usrid,-1);
} else {
system_whisper_message('Du kannst nur User bannen, die einen niedrigeren Rang haben als du!');
}
} else {
system_whisper_message('Du kannst dich nicht selbst bannen! Hier eine Alternative: <a href="http://bit.ly/eHp9VX">bit.ly/eHp9VX</a>');
}
} else {
system_whisper_message('Der User '.$name.' existiert nicht!');
}
} elseif ($in_p[1] == '/setlevel' && $data['level'] >= 2) {
array_shift($in_p);
array_shift($in_p);
$text = implode(' ',$in_p);
$text_p = explode(" ",$text);
$name = $text_p[0];
$level = (int)$text_p[1];
if ($usrid = guibn($name)) {
$udata = query("SELECT * FROM ".PREFIX."users WHERE id = ".$usrid." LIMIT 1");
$udata = $udata->fetch_assoc();
if ($udata['level'] < $data['level']) {
if ($level < $data['level']) {
if (is_int($level) && $level > -100 && $level < 100) {
set_level($usrid,$level);
system_message($name.' wurde auf das Rechte-Level '.$level.' versetzt.');
} else {
system_whisper_message($level.' ist kein g&uuml;ltiges Level!');
}
} else {
system_whisper_message('Du kannst jemanden maximal auf die Levelh&ouml;he bef&ouml;rdern, die eine unter deiner ist!');
}
//set_level($usrid,-1);
} else {
system_whisper_message('Du kannst den Rang von '.$name.' nicht ver&auml;ndern, da der momentane Rang dieses Users nicht kleiner ist als deiner!');
}
} else {
system_whisper_message('Der User '.$name.' existiert nicht!');
}
} elseif ($in_p[1] == '/blabefehl' && $data['level'] >= 2) {
system_message("blablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablablabla");
} elseif ($in_p[1] == '/gebrabbel' && $data['level'] >= 2) {
system_message('<br />Ey warum m&uuml;sst ihr mich, das OCS, mit eurem sinnlosen Gebrabbel so qu&auml;len? F&uuml;r jede Nachricht muss ich mich mit der Datenbank verbinden und tausende Abfragen machen, damit diese besch...**!* Nachricht dann hier auftaucht!<br />Ich mein, ich bin ja f&uuml;r\'s chatten programmiert, aber eure Spamattacken lassen bei mir echt den Kragen platzen!<br />Glaubt ihr ich hab Lust die ganze Zeit eure Nachrichten in m&uuml;hsamer Kleinarbeit in diese sch*** Datenbank zu schreiben und dauernd wieder auszulesen um sie euch immer und immer wieder vor die Nase zu reiben? NEIN, VERDAMMT!<br />Mann ey, jetzt rei&szlig;t euch doch mal zusammen ihr Spackos!');
} elseif ($in_p[1] == '/system' && $data['level'] >= 2) {
array_shift($in_p);
array_shift($in_p);
$text = implode(' ',$in_p);
system_message($text);
} elseif ($in_p[1] == '/powner') {
@$name = $in_p[2];
if (!empty($name)) {
if ($pid = guibn($name)) {
if ($party) {
if (in_party($pid, $party['id'])) {
if ($party['owner_id'] == $user_id || $data['level'] >= 2) {
if ($pid != $user_id || $data['level'] >= 2) {
if ($party['owner_id'] != $pid) {
$cflags['partymembers'] = -1;
query("UPDATE ".PREFIX."parties SET owner_id = $pid WHERE id = ".$party['id']." LIMIT 1");
$party['owner_id'] = $pid;
if ($party['owner_id'] == $user_id) {
system_message('<u>'.$data['username'].'</u> hat sich zum neuen Partybesitzer gemacht.');
} else {
system_message($data['username'].' hat <u>'.$name.'</u> zum neuen Partybesitzer gemacht.');
}
} else {
system_whisper_message('Der User '.$name.' ist bereits der Partybesitzer.');
}
} else {
system_whisper_message('Du kannst dich nicht selbst zum Partybesitzer machen!');
}
} else {
system_whisper_message('Du musst der Partybesitzer sein, um einen neuen ernennen zu k&ouml;nnen!');
}
} else {
system_whisper_message('Der User '.$name.' ist nicht in der Party.');
}
} else {
system_whisper_message('Hier ist keine Party.');
}
} else {
system_whisper_message('Der User '.$name.' existiert nicht!');
}
} else {
system_whisper_message('Es muss ein Username angegeben werden!');
}
} elseif ($in_p[1] == '/config' && $data['level'] >= 3) {
$name = $in_p[2];
@$value = $in_p[3];
$conf = query("SELECT * FROM ".PREFIX."configurations WHERE name = '".escape_string($name)."' LIMIT 1");
if ($conf->num_rows == 0) {
system_whisper_message("Eine Konfiguration mit dem Namen '".$name."' wurde nicht gefunden!");
} else {
$conf = $conf->fetch_object();
if (!isset($value)) {
system_whisper_message("Die Konfiguration '".$conf->name."' hat momentan den Wert '".$conf->value."'.");
} else {
query("UPDATE ".PREFIX."configurations SET value = '".$value."' WHERE id = ".$conf->id." LIMIT 1");
system_message("Der Konfiguration '".$conf->name."' wurde der Wert '".$value."' zugewiesen.");
}
}
} elseif ($in_p[1] == '/keksgeb' && !$muted /*&& $data['level'] >= 2*/) {
$user = $in_p[2];
if ($id = guibn($user)) {
system_whisper_message($data['username'].' hat dir einen imagin&auml;ren Keks gegeben. Lass ihn dir schmecken!',$id);
system_whisper_message('Du hast '.$user.' einen imagin&auml;ren Keks gegeben.');
} else {
system_whisper_message('Der User '.$user.' existiert nicht');
}
} elseif ($in_p[1] == '/glueckskeksgeb' && $data['level'] >= 2) {
$user = $in_p[2];
array_shift($in_p);
array_shift($in_p);
array_shift($in_p);
$text = implode(' ',$in_p);
if ($id = guibn($user)) {
system_whisper_message('Ein freundlicher Asiate namens '.$data['username'].' hat dir einen imagin&auml;ren Gl&uuml;ckskeks gegeben. Du liest den Zettel: '.$text,$id);
system_whisper_message('Du hast '.$user.' einen imagin&auml;ren Gl&uuml;ckskeks gegeben mit folgendem Text: '.$text);
} else {
system_whisper_message('Der User '.$user.' existiert nicht');
}
} elseif ($in_p[1] == '/keksgebinpublic' && $data['level'] >= 2) {
$user = $in_p[2];
if ($id = guibn($user)) {
system_message($data['username'].' hat '.$user.' einen imagin&auml;ren Keks gegeben. Lass ihn dir schmecken!');
} else {
system_whisper_message('Der User '.$user.' existiert nicht');
}
} elseif ($in_p[1] == '/luckyocs' && $data['level'] >= 2) {
system_message('Das OCS w&uuml;nscht allen Teilnehmern dieser Party viel Erfolg!');
} elseif ($in_p[1] == '/gross' && $data['level'] >= 2) {
array_shift($in_p);
array_shift($in_p);
$text = implode(' ',$in_p);
default_post('<span style="font-size:26px;">'.$text.'</span>');
} elseif ($in_p[1] == '/sehrgross' && $data['level'] >= 2) {
array_shift($in_p);
array_shift($in_p);
$text = implode(' ',$in_p);
default_post('<span style="font-size:40px;">'.$text.'</span>');
} elseif ($in_p[1] == '/klein' && $data['level'] >= 2) {
array_shift($in_p);
array_shift($in_p);
$text = implode(' ',$in_p);
default_post('<span style="font-size:11px;">'.$text.'</span>');
} elseif ($in_p[1] == '/sehrklein' && $data['level'] >= 2) {
array_shift($in_p);
array_shift($in_p);
$text = implode(' ',$in_p);
default_post('<span style="font-size:9px;">'.$text.'</span>');
} elseif ($in_p[1] == '/zuklein' && $data['level'] >= 2) {
array_shift($in_p);
array_shift($in_p);
$text = implode(' ',$in_p);
default_post('<span style="font-size:7px;">'.$text.'</span>');
} elseif ($in_p[1] == '/tetris' && $data['level'] >= 2) {
if (MUSIC_ON == 0) system_whisper_message('Die Musik-Funktion ist derzeit abgeschaltet'); else
system_message('TETRIS! by '.$data['username'].'<script type="text/javascript">start_music(\'tetris.mp3\');</script>');
} elseif ($in_p[1] == '/supermario' && $data['level'] >= 2) {
if (MUSIC_ON == 0) system_whisper_message('Die Musik-Funktion ist derzeit abgeschaltet'); else
system_message('SUPER MARIO! by '.$data['username'].'<script type="text/javascript">start_music(\'http://www.supermariobrothers.org/music/mario64-maintheme.mp3\');</script>');
} elseif ($in_p[1] == '/psycho' && $data['level'] >= 2) {
if (MUSIC_ON == 0) system_whisper_message('Die Musik-Funktion ist derzeit abgeschaltet'); else
system_message('PSYCHO! by '.$data['username'].'<script type="text/javascript">start_music(\'psycho.mp3\');</script>');
} elseif ($in_p[1] == '/lol' && $data['level'] >= 2) {
if (MUSIC_ON == 0) system_whisper_message('Die Musik-Funktion ist derzeit abgeschaltet'); else
system_message('LOL! by '.$data['username'].'<script type="text/javascript">start_music(\'lachanfall.MP3\');</script>');
} elseif ($in_p[1] == '/missionimpossible' && $data['level'] >= 2) {
if (MUSIC_ON == 0) system_whisper_message('Die Musik-Funktion ist derzeit abgeschaltet'); else
system_message('Mission impossible! by '.$data['username'].'<script type="text/javascript">start_music(\'missionimpossible.mp3\');</script>');
} elseif ($in_p[1] == '/rubikscubemusic' && $data['level'] >= 2) {
if (MUSIC_ON == 0) system_whisper_message('Die Musik-Funktion ist derzeit abgeschaltet'); else
system_message('Rubiks Cube Music! by '.$data['username'].'<script type="text/javascript">start_music(\'rubikscube.mp3\');</script>');
} elseif ($in_p[1] == '/gentle_breeze' && $data['level'] >= 2) {
if (MUSIC_ON == 0) system_whisper_message('Die Musik-Funktion ist derzeit abgeschaltet'); else
system_message('Gentle Breeze! by '.$data['username'].'<script type="text/javascript">start_music(\'gentle_breeze.mp3\');</script>');
} elseif ($in_p[1] == '/heyye' && $data['level'] >= 2) {
system_message('<audio controls="controls" src="heyye.ogg" type="audio/ogg"></audio>');
} elseif ($in_p[1] == '/audio' && $data['level'] >= 2) {
if (MUSIC_ON == 0) system_whisper_message('Die Musik-Funktion ist derzeit abgeschaltet'); else {
if (count($in_p) < 4) $in_p[3] = '0';
if (count($in_p) < 5) $in_p[4] = '0';
$attr = '';
if ($in_p[3] == '1') $attr .= ' autoplay';
if ($in_p[4] == '1') $attr .= ' loop';
system_message($data['username'].'<audio controls="controls" src="'.$in_p[2].'" type="audio/ogg"'.$attr.'></audio>');
}
} elseif ($in_p[1] == '/gaudio' && $data['level'] >= 3) {
if (MUSIC_ON == 0) system_whisper_message('Die Musik-Funktion ist derzeit abgeschaltet'); else {
if (count($in_p) < 4) $in_p[3] = '0';
if (count($in_p) < 5) $in_p[4] = '0';
$attr = '';
if ($in_p[3] == '1') $attr .= ' autoplay';
if ($in_p[4] == '1') $attr .= ' loop';
system_message($data['username'].'<audio controls="controls" src="http://'.$in_p[2].'" type="audio/ogg"'.$attr.'></audio>');
}
} elseif (($in_p[1] == '/mm' || $in_p[1] == '/magischemiesmuschel' || (strtolower($in_p[1]) == 'oh' && strtolower($in_p[2]) == 'magische' && (strtolower($in_p[3]) == 'miesmuschel' || strtolower($in_p[3]) == 'miesmuschel,'))) && $data['level'] >= 1 && !$muted) {
$by_text = false;
if (strtolower($in_p[1]) == 'oh' && strtolower($in_p[2]) == 'magische' && (strtolower($in_p[3]) == 'miesmuschel' || strtolower($in_p[3]) == 'miesmuschel,')) $by_text = true;
array_shift($in_p);
array_shift($in_p);
if ($by_text) {
array_shift($in_p);
array_shift($in_p);
}
$text = implode(' ',$in_p);
if (strlen($text) > MAX_CHAT_LENGTH) {
$text = substr($text,0,MAX_CHAT_LENGTH);
}
default_post('<span style="color:#5cc6fe;">Oh magische Miesmuschel, '.$text.'</span>');
$response_text[0] = 'Gar nichts.';
$response_text[1] = 'Gar nichts.';
$response_text[2] = 'Keins von beidem.';
$response_text[3] = 'ich glaub\' eher nicht.';
$response_text[4] = 'Eines Tages vielleicht.';
$response_text[5] = 'Nein.';
$response_text[6] = 'Nein.';
$response_text[7] = 'Nein.';
$response_text[8] = 'Ja.';
$response_text[9] = 'Frag doch einfach nochmal!';
$response_text[10] = 'Nein!';
$response_text[11] = 'Ja.';
$random = rand(0, 11);
$response_text = $response_text[$random];
$response_script = '<script type="text/javascript">start_music(\'mm/mm'.($random+1).'.mp3\');</script>';
$text = '<span style="color:#5cc6fe;"><b>Magische Miesmuschel</b>: '.$response_text.'</span>';
if (MUSIC_ON) $text .= $response_script;
system_message($text);
} elseif ($in_p[1] == '/getip' && $data['level'] >= 2) {
$res = query("SELECT ip FROM ".PREFIX."users WHERE username = '".escape_string($in_p[2])."'");
if ($res->num_rows == 0) system_whisper_message('Der User <u>'.$in_p[2].'</u> wurde nicht gefunden!');
else {
$res = $res->fetch_row();
$res = $res[0];
system_whisper_message('Der User <u>'.$in_p[2].'</u> hat folgende IP: <u>'.$res.'</u>');
}
} elseif ($in_p[1] == '/getaccounts' && $data['level'] >= 2) {
$res = query("SELECT username FROM ".PREFIX."users WHERE ip = '".escape_string($in_p[2])."'");
if ($res->num_rows == 0) system_whisper_message('Kein User mit der IP-Adresse <u>'.$in_p[2].'</u> wurde gefunden!');
else {
while ($r = $res->fetch_row()) {
system_whisper_message('Der User <u>'.$r[0].'</u> hat folgende IP: <u>'.$in_p[2].'</u>');
}
}
} elseif ($in_p[1] == '/getduplicates' && $data['level'] >= 2) {
$ip = query("SELECT ip FROM ".PREFIX."users WHERE username = '".escape_string($in_p[2])."'");
if ($ip->num_rows == 0) system_whisper_message('Der User <u>'.$in_p[2].'</u> wurde nicht gefunden!');
else {
$ip = $ip->fetch_row();
$ip = $ip[0];
$res = query("SELECT username FROM ".PREFIX."users WHERE ip = '".$ip."' AND username != '".escape_string($in_p[2])."'");
if ($res->num_rows == 0) system_whisper_message('Kein weiterer User mit der selben IP-Adresse wie <u>'.$in_p[2].'</u> wurde gefunden!');
else {
while ($r = $res->fetch_row()) {
system_whisper_message('Der User <u>'.$r[0].'</u> hat dieselbe IP wie <u>'.$in_p[2].'</u>');
}
}
}
} elseif ($in_p[1] == '/manwhore' && $data['level'] >= 2) {
default_post("<br />Lust so gro&szlig; wie Brontosaurus<br />Liebe wie ein totes Walross<br />Wahre Liebe ist kein Trugbild<br />Hart und fest wirst du verriegelt<br /><br />Steig auf mein treues Gest&uuml;t<br />Wo der s&uuml;&szlig;e Samen bl&uuml;ht<br />Nun nimm mich ganz mit Herz und Zepter<br />So mein Sch&ouml;pfer Velociraptor<br /><br />Ich schwing mein Lustrieb wie ne Axt<br />Sehr warm und klebrig so wie Wachs<br />Noch kennst du nicht solch s&uuml;&szlig;e Lust<br />Wiederstehst du mein Mannesduft<br /><br />Rot wie Rosen, blau wie Veilchen<br />Ich muss den Jogurt auf dich streichen<br />Von nun an gibt es kein zur&uuml;ck<br />Nur deshalb rauche ich noch Crack<br /><br />Mein Vater hat mich nie geliebt<br /><br />Lust ist wie ein Tintenfisch<br />Sie stinkt, doch ist verf&uuml;hrerisch<br />Nun kratz den Ausschlag auf meinen Arsch<br />Der Juckreiz macht mich richtig scharf<br /><br />Jogurt wird gut nur kalt serviert<br />Was fehlt auf dem Rezept notiert<br />Heut Nacht habe ich Sex mit dir<br />Dann kochst du etwas mit mir<br /><br />Jetzt leg dich hin und gib dich her<br />Ich schw&ouml;re dir es schmerzt nicht sehr<br />Dich hart zu reiten ist meine Pflicht<br />Komm n&auml;her! Fernado bei&szlig;t nicht<br /><br />Leid und Lust aus Schmerzensschreien<br />Sind Geschenke die wir teilen<br />Tief durchschwitzt mit s&uuml;&szlig;em Wein<br />Ist dies Blut, Deins oder Mein<br />");
if (MUSIC_ON == 1) system_message('Manwhore: '.$data['username'].'<script type="text/javascript">start_music(\'manwhore.mp3\');</script>');
} elseif ($in_p[1] == '/ud' && $data['level'] >= 6) {
array_shift($in_p);
array_shift($in_p);
$text = implode(' ',$in_p);
if (strlen($text) > MAX_CHAT_LENGTH) {
$text = substr($text,0,MAX_CHAT_LENGTH);
}
default_post(upsideDown($text));
} elseif ($in_p[1] == '/no' && $data['level'] >= 6) {
default_post('<img src="images/no.png" />');
} elseif ($in_p[1] == '/banip' && $data['level'] >= 3) {
//$block1 = $in_p[2];
if (empty($in_p[2])) system_whisper_message("Du musst mindestens einen IP-Block angeben!");
else {
$block1 = (int)$in_p[2];
if ($block1 == '-1') system_whisper_message("Felk: Ich hab schonmal einen Sternchenbann auf * gemacht. Es war eine dumme Idee.");
else {
if (empty($in_p[3])) $block2 = -1;
else $block2 = (int)$in_p[3];
if (empty($in_p[4])) $block3 = -1;
else $block3 = (int)$in_p[4];
if (empty($in_p[5])) $block4 = -1;
else $block4 = (int)$in_p[5];
$db->query("INSERT INTO ".PREFIX."asterisk_bans (block1, block2, block3, block4, user_id) VALUES ($block1, $block2, $block3, $block4, ".$data['id'].")");
system_whisper_message("Sternchenbann durchgef&uuml;hrt auf: $block1 $block2 $block3 $block4");
}
}
} elseif ($in_p[1] == '/gencode' && $data['level'] >= 1) {
InvitationManager::deleteDecayedCodes($db);
$codes = InvitationManager::getCodesByUser($db, $data['id']);
if ($codes->num_rows >= 3 && $data['level'] < 2) {
$row = $codes->fetch_object();
$mintime = $row->decay_time;
while($row = $codes->fetch_object())
if ($row->decay_time < $mintime) $mintime = $row->decay_time;
$hours = number_format(($mintime-time())/3600, 1);
system_whisper_message("Du hast bereits 3 Einladungscodes generiert. Diese kannst du per /getcodes abrufen.");
} else {
system_whisper_message("Folgender Einladungscode ist f&uuml;r ".round(INVITATION_CODE_DECAY/3600)." Stunden g&uuml;ltig: <b>".InvitationManager::generateNewCode($db, $data['id'])."</b>");
}
} elseif ($in_p[1] == '/getcodes' && $data['level'] >= 1) {
InvitationManager::deleteDecayedCodes($db);
$codes = InvitationManager::getCodesByUser($db, $data['id']);
if ($codes->num_rows == 0) {
system_whisper_message("Du hast derzeit keine Einladungscodes. Generiere welche mit /gencode.");
} else {
$text = "Folgende Einladungscodes sind noch g&uuml;ltig:";
while($row = $codes->fetch_object()) {
$now = time();
$hours = number_format(($row->decay_time-$now)/3600, 1);
$text .= " - <b>".$row->code."</b> (Noch $hours Stunden)";
}
system_whisper_message($text);
}
} elseif ($in_p[1] == '/track' && $data['level'] >= 2) {
$user = $in_p[2];
if ($userid = guibn($user)) {
$origin = query("SELECT origin FROM ".PREFIX."users WHERE id = ".$userid." LIMIT 1");
$origin = $origin->fetch_row() or die("<b>Sag Felk, dass sein /track an Stelle 1 nicht klappt!</b>");
$origin = $origin[0];
if ($origin == '') {
system_whisper_message('Der Account <u>'.$user.'</u> wurde offensichtlich vor V 0.71 erstellt und hat daher <u>keine Herkunft</u>.');
} elseif (substr($origin, 0, 1) == '#') {
$codestr = substr($origin, 1);
$code = InvitationManager::getCodeAssoc($db, $codestr);
if ($code === null) system_whisper_message('Der Account <u>'.$user.'</u> wurde mit dem Code <u>'.$codestr.'</u> erstellt, zu dem es keine Informationen mehr gibt.');
else {
if (!($originusername = gunbi($code['user_id']))) die("<b>Sag Felk, dass sein /track an Stelle 2 nicht klappt!</b>");
system_whisper_message('Der Account <u>'.$user.'</u> wurde mit dem Code <u>'.$code['code'].'</u> erstellt. Dieser wurde am '.date("d.m.Y H:i", $code['time']).' von <u>'.$originusername.'</u> generiert.');
}
} else {
system_whisper_message('Der Account <u>'.$user.'</u> wurde mit dem Forenaccount <u>'.$origin.'</u> erstellt.');
}
} else {
system_whisper_message('Der User <u>'.$user.'</u> wurde nicht gefunden!');
}
} elseif ($in_p[1] == '/ignore') {
$user = $in_p[2];
if ($userid = guibn($user)) {
$blocked = query("SELECT * FROM ".PREFIX."ignorelist WHERE user_id = ".$data['id']." AND target_id = ".$userid." LIMIT 1");
if ($blocked->num_rows == 0) {
query("INSERT INTO ".PREFIX."ignorelist (user_id, target_id) VALUES (".$data['id'].", ".$userid.")");
system_whisper_message("<b>Du hast <u>".$user."</u> ignoriert!</b> (Hat der User einen h&ouml;heren Rang, dann werden die Nachrichten trotzdem angezeigt)");
} else {
system_whisper_message("Du hast den User <u>".$user."</u> bereits ignoriert.");
}
} else {
system_whisper_message('Der User <u>'.$user.'</u> wurde nicht gefunden!');
}
} elseif ($in_p[1] == '/unignore') {
$user = $in_p[2];
if ($userid = guibn($user)) {
$blocked = query("SELECT * FROM ".PREFIX."ignorelist WHERE user_id = ".$data['id']." AND target_id = ".$userid." LIMIT 1");
if ($blocked->num_rows == 1) {
query("DELETE FROM ".PREFIX."ignorelist WHERE user_id = ".$data['id']." AND target_id = ".$userid." LIMIT 1");
system_whisper_message("<b>Du ignorierst <u>".$user."</u> nicht l&auml;nger!</b>");
} else {
system_whisper_message("Du hast den User <u>".$user."</u> nicht ignoriert.");
}
} else {
system_whisper_message('Der User <u>'.$user.'</u> wurde nicht gefunden!');
}
} elseif ($in_p[1] == '/ignorelist') {
$list = query("SELECT target_id FROM ".PREFIX."ignorelist WHERE user_id = ".$user_id);
if ($list->num_rows == 0) system_whisper_message("Du hast <u>niemanden</u> ignoriert.");
else {
$row = $list->fetch_row();
$str = gunbi($row[0]);
while ($row = $list->fetch_row()) {
$str .= ', '.gunbi($row[0]);
}
system_whisper_message("Du hast folgende Leute ignoriert: <u>$str</u>");
}
} elseif ($in_p[1] == '/mute' && $data['level'] >= 2) {
if (count($in_p) < 4) system_whisper_message("Korrekte Anwendung: /mute Name Dauer(s,m,h,d,w,a)");
else {
$userid = guibn($in_p[2]);
if ($userid == false) {
system_whisper_message("User nicht erkannt.");
} else {
$dur = timestrToSeconds($in_p[3]);
if ($dur < 0) {
system_whisper_message("Fehlerhafte Zeitangabe.");
} else {
system_message("<b>".$in_p[2]." wurde von ".$data['username']." f&uuml;r ".getDurationString($dur)." gemuted!</b>");
addMute($userid, $data['id'], $dur);
}
}
}
} elseif ($in_p[1] == '/unmute' && $data['level'] >= 2) {
if (count($in_p) < 3) system_whisper_message("Korrekte Anwendung: /unmute Name");
else {
$userid = guibn($in_p[2]);
if ($userid == false) {
system_whisper_message("User nicht erkannt.");
} else {
removeMutes($userid);
system_message($data['username']." hat ".$in_p[2]." entmuted.");
}
}
} elseif ($in_p[1] == '/channel' && $data['level'] >= 2) {
if (in_array($in_p[2], array('delete', 'remove', 'erase', 'kill', 'destroy', 'extinguish', 'obliterate', 'close', 'annihilate', 'crush', 'nuke'))) {
$id = $data['last_channel'];
$channel = query("SELECT COUNT(*) FROM ".PREFIX."channels WHERE id = $id AND owner_id != '' LIMIT 1");
$channel = $channel->fetch_row();
$channel = $channel[0];
if ($channel == 0) {
system_whisper_message('Dieser Channel ist nicht privat!');
} else {
deleteChannel($id);
}
} else
system_whisper_message('M&ouml;gliche Attribute f&uuml;r /channel: delete, remove, erase, kill, destroy, extinguish, obliterate, close, annihilate, crush, nuke');
} else {
if ($muted) {
$count = count($mute_messages);
$num = rand(0, $count);
@$troll = $_SESSION['MUTE_TROLL'];
if ($troll === true) {
system_whisper_message("Hah, verarscht!");
$_SESSION['MUTE_TROLL'] = false;
} else if ($num == $count) {
system_whisper_message("Wenn du wieder sprechen m&ouml;chtest, so schreibe bitte 'Entschuldigung' in den Chat.");
$_SESSION['MUTE_TROLL'] = true;
} else {
system_whisper_message($mute_messages[$num]);
}
//system_whisper_message("Du kannst das momentan nicht tun!");
} else {
array_shift($in_p);
$text = implode(' ',$in_p);
if (strlen($text) > MAX_CHAT_LENGTH) {
$text = substr($text,0,MAX_CHAT_LENGTH);
}
if (substr($text,0,1) == '/')
system_whisper_message("Das Kommando ".$in_p[0]." wurde nicht erkannt. Vertippt?");
else
default_post($text);
}
}
}
$in_p[0] = "UPDATE_ALL";
} if ($in_p[0] == "UPDATE_CHANNELS" || $in_p[0] == "UPDATE_ALL") {
if (($cflags['channels'] % UPDATE_CHANNELS_PAUSES) == 0) {
echo '<table class="t_list" cellspacing="0" cellpadding="1"><tbody>';
echo '<tr><td align="center" colspan="2"><u>&Ouml;ffentliche Channel:</u></td></tr>';
$result = query("SELECT * FROM ".PREFIX."channels WHERE owner_id = '' ORDER BY sorting");
while($row = $result->fetch_object()) {
echo '<tr><td>- ';
if ($channel_id == $row->id) {
echo '<span style="color:green; font-weight: bold;">'.$row->name.'</span>';
} else {
if ($row->password != '') {
echo '<a style="color:red;" onclick="enter_channel('.$row->id.', true)" href="#">'.$row->name.'</a>';
} else {
echo '<a onclick="enter_channel('.$row->id.')" href="#">'.$row->name.'</a>';
}
}
echo '</td><td>('.get_users_num($row->id).')</td></tr>';
}
echo '<tr><td align="center" colspan="2"><u>private Channel:</u></td></tr>';
$result = query("SELECT c.* FROM ".PREFIX."channels as c WHERE c.owner_id != '' ORDER BY (SELECT COUNT(*) FROM ".PREFIX."users as u WHERE u.last_channel = c.id) DESC, c.id DESC LIMIT 10");
while($row = $result->fetch_object()) {
echo '<tr><td>- ';
if ($channel_id == $row->id) {
echo '<span style="color:green; font-weight: bold;">'.$row->name.'</span>';
} else {
if ($row->password != '') {
echo '<a style="color:red;" onclick="enter_channel('.$row->id.', true)" href="#">'.$row->name.'</a>';
} else {
echo '<a onclick="enter_channel('.$row->id.')" href="#">'.$row->name.'</a>';
}
}
echo '</td><td>('.get_users_num($row->id).')</td></tr>';
}
echo '</tbody></table>';
}
} if ($in_p[0] == "UPDATE_CHAT" || $in_p[0] == "UPDATE_ALL") {
if ($in_p[0] == "UPDATE_ALL") echo '[ALL_S]';
$text = "";
if (empty($last_id))
$last_id = 0;
$result = query("SELECT c.id,c.user_id,text,mode,extra,DATE_FORMAT(time,\"%H:%i\") as datum FROM ".PREFIX."chat as c
WHERE c.id > $last_id
AND UNIX_TIMESTAMP(time) > UNIX_TIMESTAMP(CURRENT_TIMESTAMP)-".MAX_SHOW_LIMIT."
AND (channel_id = $channel_id
OR mode = 'shout'
OR mode = 'system_shout'
OR ((mode = 'whisper' OR mode = 'system_whisper') AND (extra = $user_id OR c.user_id = $user_id)))
ORDER BY c.id DESC LIMIT ".MAX_LOADMESSAGES);
//if ($result->num_rows > MAX_LOADMESSAGES) {
// $tomuch = $result->num_rows - MAX_LOADMESSAGES;
// for ($i=0; $i<$tomuch; $i++) $result->fetch_object();
//}
$last_id = array();
if ($result->num_rows > 0) {
while($row = $result->fetch_object()) {
if (is_ignored($data, $row->user_id) && ($row->mode == '' || $row->mode == 'whisper')) continue;
$row->text = parse_smileys($row->text);
if (false /*strlen($row->text) > MAX_CHAT_LENGTH*/) {
$row->text = substr($row->text,0,MAX_CHAT_LENGTH);
if (substr_count($row->text,'<') != substr_count($row->text,'>')) {
if ((substr_count($row->text,'"') % 2) == 1) {
$row->text .= '">';
} else {
$row->text .= '>';
}
}
}
$mode = $row->mode;
$text = '</span>'.$text;
if (TROLL) $row->text = upsideDown($row->text);
// FINDME
switch($mode) {
case 'me':
if ($user_id == $row->user_id) {
$text = '('.$row->datum.') <span class="user">'.gunbi($row->user_id).'</span> '.$row->text.'<br />'.$text;
} else {
$text = '('.$row->datum.') '.gunbi($row->user_id).' '.$row->text.'<br />'.$text;
}
break;
case 'whisper':
if ($user_id == $row->user_id) {
$text = '('.$row->datum.') <i><span style="font-weight:bold;"><span class="user"><span style="color:#'.gucbi($row->user_id).';">'.gunbi($row->user_id).
'</span></span> ('.gunbi($row->extra).'):</span> '.$row->text.'</i><br />'.$text;
} else {
$text = '('.$row->datum.') <i><span style="font-weight:bold;"><a onclick="quick_whisper(\''.gunbi($row->user_id).'\')"><span style="color:#'.gucbi($row->user_id).';">'.gunbi($row->user_id).':</span></a></span> '.$row->text.'</i><br />'.$text;
}
break;
case 'channelshout':
if ($user_id == $row->user_id) {
$text = '('.$row->datum.') <span style="color:#FF0000;"><span class="user"><b><span style="color:#'.gucbi($row->user_id).';">'.
gunbi($row->user_id).':</span></b></span> '.$row->text.'</span><br />'.$text;
} else {
$text = '('.$row->datum.') <span style="color:#FF0000;"><b><a onclick="quick_whisper(\''.gunbi($row->user_id).'\')"><span style="color:#'.gucbi($row->user_id).';">'.gunbi($row->user_id).':</span></a></b> '.$row->text.'</span><br />'.$text;
}
break;
case 'shout':
if ($user_id == $row->user_id) {
$text = '('.$row->datum.') <span style="color:#FF0000; font-weight:bold;"><span class="user"><span style="color:#'.gucbi($row->user_id).';">'.
gunbi($row->user_id).':</span></span> '.$row->text.'</span><br />'.$text;
} else {
$text = '('.$row->datum.') <span style="color:#FF0000; font-weight:bold;"><a onclick="quick_whisper(\''.gunbi($row->user_id).'\')"><span style="color:#'.gucbi($row->user_id).';">'.gunbi($row->user_id).':</span></a> '.$row->text.'</span><br />'.$text;
}
break;
case 'system':
$text = '<span style="color:#FF8C00;">('.$row->datum.') '.$row->text.'</span><br />'.$text;
break;
case 'system_whisper':
$text = '<span style="color:#FF8C00;">('.$row->datum.') <i>'.$row->text.'</i></span><br />'.$text;
break;
default:
if ($user_id == $row->user_id) {
$text = '('.$row->datum.') <b><span class="user"><span style="color:#'.gucbi($row->user_id).';">'.gunbi($row->user_id).':</span></span></b> '.$row->text.'<br />'.$text;
} else {
$text = '('.$row->datum.') <b><a onclick="quick_whisper(\''.gunbi($row->user_id).'\')"><span style="color:#'.gucbi($row->user_id).';">'.gunbi($row->user_id).':</span></a></b> '.$row->text.'<br />'.$text;
}
break;
}
$text = '<span class="messageline">'.$text;
$last_id[] = $row->id;
}
}
//echo upsideDown($text);
echo $text;
//echo '<div id="buffer"><br /></div>';
if (!empty($last_id))
echo '[LI_S]'.$last_id[0];
} if ($in_p[0] == "UPDATE_USERS" || $in_p[0] == "UPDATE_ALL") {
if ($in_p[0] == "UPDATE_ALL") echo '[ALL_S]';
if (($cflags['users'] % UPDATE_USERS_PAUSES) == 0) {
$result = query("SELECT username,id,level,status,namecolor FROM ".PREFIX."users WHERE last_channel = $channel_id AND UNIX_TIMESTAMP(last_update) > (UNIX_TIMESTAMP(CURRENT_TIMESTAMP)-".MAX_RESPONSE_LIMIT.") ORDER BY username");
echo '<table class="t_list"><tbody>';
$colspan = 3;
if ($party) {
if ($party['joining_type'] == 'invite' && $party['owner_id'] == $user_id && $current_round == 0)
$colspan++;
}
echo '<tr><td colspan="'.$colspan.'" style="font-size:16px;">User in diesem Channel:</td></tr>';
while($row = $result->fetch_object()) {
if ($user_id == $row->id) {
echo '<tr><td valign="top">-</td><td valign="top"><b><span style="color:#'.$row->namecolor.';">'.$row->username.'</span></b></td><td>';
} else {
echo '<tr><td valign="top">-</td><td valign="top"><a onclick="quick_whisper(\''.$row->username.'\')"><span style="color:#'.$row->namecolor.';">'.$row->username.'</span></a></td><td>';
}
switch($row->level) {
case 1:
if ($data['level'] > 1) echo ' <small>[1]</small>&nbsp;';
break;
case 2:
echo ' <span class="usertitle">[M]</span>&nbsp;';
break;
case 3:
echo ' <span class="usertitle">[M+]</span>&nbsp;';
break;
case 4:
echo ' <span class="usertitle">[A]</span>&nbsp;';
break;
case 5:
case 6:
echo ' <span class="usertitle">[A+]</span>&nbsp;';
break;
}
if ($user_id == $row->id) {
$is_muted = $muted;
} else {
$is_muted = isMuted($row->id);
}
if ($is_muted) {
echo '<span style="color:#cccccc; font-size:9px;">gemuted f&uuml;r '.getDurationString($is_muted).'</span>';
} else {
echo '<span style="color:yellow; font-size:9px;">'.$row->status.'</span>';
}
echo '</td>';
if ($party) {
if ($party['joining_type'] == 'invite' &&
$party['owner_id'] == $user_id &&
$current_round == 0 &&
!in_party($row->id, $party['id']) )
echo '<td><a href="#" onclick="post(\'/invite '.$row->username.'\')"><img alt="zur Party" title="zur Party" src="images/add.png" /></a></td>';
}
echo '</tr>';
}
}
} if ($in_p[0] == "UPDATE_PARTYMEMBERS" || $in_p[0] == "UPDATE_ALL") {
if ($in_p[0] == "UPDATE_ALL") echo '[ALL_S]';
if (($cflags['partymembers'] % UPDATE_PARTYMEMBERS_PAUSES) == 0) {
if ($party = get_current_party_assoc()) {
if ($current_round == 0 && $party['owner_id'] == $user_id) {
echo '[DROPDOWN_SCRAMBLES]';
}
echo '<table class="t_list" cellpadding="1" cellspacing="0"><tbody>';
echo '<tr><td style="font-size: 16px;" colspan="2" align="center"><u>'.get_party_name().'</u>';
if (!$in_party && $party['joining_type'] == 'join' && $party['active_mode'] == 'waiting') echo ' <a href="#" onclick="post(\'/join\')"><img alt="Mitmachen" title="Mitmachen" src="images/add.png"></a>';
if ($party['owner_id'] == $user_id || $data['level'] >= 2) echo ' <a href="#" onclick="post(\'/cancel\')"><img alt="Party abbrechen" title="Party abbrechen" src="images/cross.png"></a>';
echo '</td></tr>';
echo '<tr><td><b>- '.gunbi($party['owner_id']).'</b></td><td>';
if (!user_awaiting_time($party['owner_id'])) echo '<img alt="Fertig" title="Fertig" src="images/tick.png">';
echo '</td></tr>';
$members = get_party_members($party['id']);
while ($row = $members->fetch_assoc()) {
if ($row['user_id'] == $party['owner_id']) continue;
$name = gunbi($row['user_id']);
echo '<tr><td>- '.$name.'</td><td>';
if (!user_awaiting_time($row['user_id'])) echo '<img alt="Fertig" title="Fertig" src="images/tick.png">';
if ($party['owner_id'] == $user_id || ($data['level'] >= 2 && $row['user_id'] != $user_id)) echo ' <a href="#" onclick="post(\'/leave '.$name.'\')"><img alt="Kicken" title="Kicken" src="images/cross.png"></a>';
if ($party['owner_id'] == $user_id || $data['level'] >= 2) echo ' <a href="#" onclick="post(\'/powner '.$name.'\')"><img alt="Partybesitzer" title="Partybesitzer" src="images/user_go.png"></a>';
if ($row['user_id'] == $user_id) echo '<a href="#" onclick="post(\'/leave\')"><img alt="Verlassen" title="Verlassen" src="images/cross.png"></a>';
echo '</td></tr>';
}
echo '</tbody></table>';
} elseif($channel_rounds == 0) {
echo '';
} else {
echo '<table class="t_list"><tbody><tr><td><b>Party starten!</b></td></tr>'.
'<tr><td><a href="#" onclick="new_party(\'join\');return false;">- normale Party</a></td></tr>'.
'<tr><td><a href="#" onclick="new_party(\'invite\');return false;">- geschlossene Party</a></td></tr></tbody></table>';
}
}
} if ($in_p[0] == "UPDATE_AWAITINGS" || $in_p[0] == "UPDATE_ALL") {
if ($in_p[0] == "UPDATE_ALL") echo '[ALL_S]';
echo user_awaiting_time();
echo '[A_S]';
echo $awaiting_ready;
} if ($in_p[0] == "UPDATE_LAST_RESULTS" || $in_p[0] == "UPDATE_ALL") {
if ($in_p[0] == "UPDATE_ALL") echo '[ALL_S]';
if (($cflags['last_results'] % UPDATE_LAST_RESULTS_PAUSES) == 0) {
$last_party = get_last_results();
if (!$last_party) {
echo "<b>Keine Ergebnisse verf&uuml;gbar</b>";
} else {
echo display_results($last_party);
}
}
}
// not global anymore
//if ($party['active_mode'] == 'running') check_next_round();
if ($party['owner_id'] == $user_id && $party['active_mode'] == 'running') check_next_round();
//query("DELETE FROM ".PREFIX."chat WHERE UNIX_TIMESTAMP(`time`) < (UNIX_TIMESTAMP(CURRENT_TIMESTAMP)-".CHAT_DELETE_TIME.")");
$_SESSION[PREFIX.'cflags'] = $cflags;
ob_end_flush();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment