コード例 #1
0
function verlasse_chat($u_id, $u_name, $raum)
{
    // user $u_id/$u_name verlässt $raum
    // Nachricht in Raum $raum wird erzeugt
    // Liefert ID des geschriebenen Datensatzes zurück
    global $dbase, $chat, $system_farbe, $t, $lustigefeatures;
    global $eintritt_individuell, $eintritt_useranzeige;
    $back = 0;
    // Nachricht an alle
    if ($raum && $u_id) {
        $text = $t['chat_msg102'];
        if ($eintritt_individuell == "1") {
            $query = "SELECT u_austritt FROM user where u_id = {$u_id}";
            $result = mysql_query($query);
            $row = mysql_fetch_object($result);
            if (strlen($row->u_austritt) > 0) {
                $text = $row->u_austritt;
                if ($eintritt_useranzeige == "1") {
                    $text = "<b>&lt;&lt;&lt;</b> " . htmlspecialchars($text) . " (<b>{$u_name}</b> - verlässt Chat) ";
                } else {
                    $text = "<b>&lt;&lt;&lt;</b> " . htmlspecialchars($text) . " <!-- (<b>{$u_name}</b> - verlässt Chat) -->";
                }
            }
            mysql_free_result($result);
            $query = "SELECT r_name FROM raum where r_id = " . intval($raum);
            $result = mysql_query($query);
            $row = mysql_fetch_object($result);
            if (isset($row->r_name)) {
                $r_name = $row->r_name;
            } else {
                $r_name = "[unbekannt]";
            }
            mysql_free_result($result);
        }
        $text = str_replace("%u_name%", $u_name, $text);
        $text = str_replace("%user%", $u_name, $text);
        $text = str_replace("%r_name%", $r_name, $text);
        $text = preg_replace("|%nick%|i", $u_name, $text);
        $text = preg_replace("|%raum%|i", $r_name, $text);
        $back = global_msg($u_id, $raum, $text);
    }
    return $back;
}
コード例 #2
0
ファイル: server.php プロジェクト: vodaben/monopoly
function disconnect($socket)
{
    global $sockets, $users, $db, $playroom;
    $found = null;
    $n = count($users);
    for ($i = 0; $i < $n; $i++) {
        if ($users[$i]->socket == $socket) {
            $found = $i;
            //console(var_dump($users[$i]));
            $room = new Room($db);
            if ($users[$i]->rid > 0) {
                //kick the user out of the room
                $room->leaveroom($users[$i]->rid);
                foreach ($playroom as $proom) {
                    if ($proom->rid == $users[$i]->rid) {
                        foreach ($proom->players as $key => $kplayer) {
                            if ($users[$i]->name == $kplayer->name) {
                                console("the name is:" . $kplayer->name);
                                console("the second name is:" . $users[$i]->name);
                                unset($proom->players[$key]);
                            }
                        }
                    }
                    break;
                }
                console("please:" . var_dump($playroom));
                $users[$i]->rid = 0;
                //should not be in any room
                $send_packet = array();
                //another packet for all users
                $send_packet["act"] = "roomlist";
                $send_packet["roomlist"] = $room->getroomlist(1);
                global_msg(json_encode($send_packet));
            }
            break;
        }
    }
    if (!is_null($found)) {
        array_splice($users, $found, 1);
    }
    $index = array_search($socket, $sockets);
    socket_close($socket);
    //foreach ($users as $u) {
    //send($u->socket,"[GLOBAL MESSAGE] User ".$users[$found]->id." disconnect!<br/>");
    //}
    console($socket . " DISCONNECTED!");
    if ($index >= 0) {
        array_splice($sockets, $index, 1);
    }
    update_player_list();
    //update the player list
}
コード例 #3
0
ファイル: edit.php プロジェクト: netzhuffle/mainchat
 }
 // Userdaten schreiben
 if ($ok) {
     if (isset($zeige_loesch) && $zeige_loesch != 1) {
         // Änderungen anzeigen
         $query = "SELECT o_userdata,o_userdata2,o_userdata3,o_userdata4,o_raum " . "FROM online " . "WHERE o_user="******"<P><B>" . str_replace("%u_name%", htmlspecialchars($f['u_name']), $t['edit8']) . "</B></P>\n";
             }
             if ($f['u_nick'] and $f['u_nick'] != $userdata['u_nick']) {
                 echo "<P><B>" . str_replace("%u_nick%", $f['u_nick'], $t['edit9']) . "</B></P>\n";
                 global_msg($u_id, $row->o_raum, str_replace("%u_nick%", $f['u_nick'], str_replace("%row->u_nick%", $userdata['u_nick'], $t['edit10'])));
             }
         }
         @mysql_free_result($result);
         echo "<P><B>{$t['edit11']}</B></P>\n";
     }
     $query = "SELECT u_profil_historie FROM user WHERE u_id = " . intval($f['u_id']);
     $result = mysql_query($query);
     $g = mysql_fetch_array($result);
     $g['u_profil_historie'] = unserialize($g['u_profil_historie']);
     $datum = time();
     $u_profil_historie_neu[$datum] = $u_nick;
     if (is_array($g['u_profil_historie'])) {
         $i = 0;
         while ($i < 3 && (list($datum, $nick) = each($g['u_profil_historie']))) {
             $u_profil_historie_neu[$datum] = $nick;
コード例 #4
0
ファイル: functions-msg.php プロジェクト: netzhuffle/mainchat
function sperre($r_id, $u_id, $u_name, $s_user, $s_user_name, $admin)
{
    // Sperrt User s_user für Raum r_id oder hebt Sperre auf
    // Wirft User ggf aus dem Raum r_id
    global $lobby;
    global $dbase;
    global $timeout;
    global $t;
    global $u_level;
    global $conn;
    // Id der Lobby als Voreinstellung ermitteln
    $query = "SELECT r_id FROM raum WHERE r_name LIKE '{$lobby}' ";
    $result = mysql_query($query, $conn);
    $rows = mysql_num_rows($result);
    if ($rows > 0) {
        $lobby_id = mysql_result($result, 0, "r_id");
    } else {
        system_msg("", 0, $u_id, $system_farbe, $t['sperre1']);
    }
    mysql_free_result($result);
    if ($r_id != $lobby_id) {
        $query = "SELECT s_id FROM sperre " . "WHERE s_user={$s_user} " . "AND  s_raum={$r_id}";
        $result = mysql_query($query, $conn);
        $rows = mysql_num_rows($result);
        if ($rows == 0) {
            // Ist User s_user in diesem Raum? $o_id ermitteln
            $query2 = "SELECT o_id FROM online " . "WHERE o_raum={$r_id} " . "AND o_user={$s_user} " . "AND (UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP(o_aktiv)) <= {$timeout} ";
            $result2 = mysql_query($query2, $conn);
            $rows2 = mysql_num_rows($result2);
            if ($rows2 > 0) {
                // Sperre neu setzen
                $o_id = mysql_result($result2, 0, "o_id");
                $f['s_user'] = $s_user;
                $f['s_raum'] = $r_id;
                schreibe_db("sperre", $f, "", "s_id");
                // User aus Raum werfen
                global_msg($u_id, $r_id, "'{$u_name}' {$t['sperre2']} '{$s_user_name}' {$t['sperre3']}");
                raum_gehe($o_id, $s_user, $s_user_name, $r_id, $lobby_id, FALSE);
            } else {
                // User ist nicht in diesem Raum... meldung ausgeben.
                system_msg("", 0, $u_id, $system_farbe, str_replace("%s_user_name%", $s_user_name, $t['sperre4']));
                // trotzdem in Seprre eintragen.
                $f['s_user'] = $s_user;
                $f['s_raum'] = $r_id;
                schreibe_db("sperre", $f, "", "s_id");
            }
        } else {
            // Sperre löschen
            $s_id = mysql_result($result, 0, "s_id");
            $query2 = "DELETE FROM sperre WHERE s_id={$s_id} ";
            $result2 = mysql_query($query2, $conn);
            global_msg($u_id, $r_id, "'{$u_name}' {$t['sperre2']} '{$s_user_name}' {$t['sperre5']}");
        }
        mysql_free_result($result);
    } else {
        // User ist in Lobby
        if (!($admin || $u_level == "A")) {
            system_msg("", 0, $u_id, $system_farbe, $t['sperre6']);
        } else {
            // User aus Chat werfen
            // Ist User s_user in diesem Raum? $o_id ermitteln
            $query2 = "SELECT o_id FROM online " . "WHERE o_raum={$r_id} " . "AND o_user={$s_user} " . "AND (UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP(o_aktiv)) <= {$timeout} ";
            $result2 = mysql_query($query2, $conn);
            $rows2 = mysql_num_rows($result2);
            if ($rows2 > 0) {
                // User rauswerfen
                $o_id = mysql_result($result2, 0, "o_id");
                global_msg($u_id, $r_id, "'{$u_name}' {$t['sperre2']} '{$s_user_name}' {$t['sperre7']}");
                // 2 sek vor dem ausloggen warten, damit der Störer die Meldung auch noch lesen kann !!!
                sleep(2);
                verlasse_chat($s_user, $s_user_name, $r_id);
                sleep(2);
                logout($o_id, $s_user, "sperre in lobby");
            } else {
                system_msg("", 0, $u_id, $system_farbe, str_replace("%s_user_name%", $s_user_name, $t['sperre4']));
            }
        }
    }
}
コード例 #5
0
function nachricht_verlasse($r_id, $u_name, $r_name)
{
    // Eintrittsnachricht in Raum schreiben
    // Aufruf mit Raum-Id, UserName, Raum-Name
    // liefert $back (ID des geschriebenen Datensatzes) zurück
    global $chat, $nachricht_v, $lustigefeatures, $u_farbe, $u_id;
    global $eintritt_individuell, $eintritt_useranzeige;
    // Nachricht Standard
    $text = $nachricht_v[0];
    // Nachricht Lustiege ein/austrittsnachrichten
    if ($lustigefeatures) {
        reset($nachricht_v);
        $anzahl = count($nachricht_v);
        $text = $nachricht_v[mt_rand(1, $anzahl) - 1];
    }
    // Nachricht auswählen
    if ($eintritt_individuell == "1") {
        $query = "SELECT u_austritt FROM user where u_nick = '" . mysql_real_escape_string($u_name) . "'";
        $result = mysql_query($query);
        $row = mysql_fetch_object($result);
        if (strlen($row->u_austritt) > 0) {
            $text = $row->u_austritt;
            if ($eintritt_useranzeige == "1") {
                $text = htmlspecialchars($text) . "  <b>({$u_name})</b> ";
            } else {
                $text = htmlspecialchars($text) . " <!-- <b>({$u_name})</b> -->";
            }
        }
        mysql_free_result($result);
    }
    $text = str_replace("%u_name%", $u_name, $text);
    $text = str_replace("%r_name%", $r_name, $text);
    $text = preg_replace("|%nick%|i", $u_name, $text);
    $text = preg_replace("|%raum%|i", $r_name, $text);
    if (strlen($text) == 0) {
        $text = $u_name;
    }
    // Nachricht im Chat ausgeben; falls Raum moderiert ist, nur HTML-Kommentar ausgeben
    if (raum_ist_moderiert($r_id)) {
        $back = system_msg("", 0, $u_id, $u_farbe, "<b>&lt;&lt;&lt;</b> " . $text);
    } else {
        $back = global_msg($u_id, $r_id, "<b>&lt;&lt;&lt;</b> " . $text);
    }
    return $back;
}