function sms_msg($von_user, $von_user_id, $an_user, $farbe, $text, $userdata = "")
{
    // Schreibt privaten Text von $von_user an User $an_user
    // Art:           N: Normal
    //                S: Systemnachricht
    //                P: Privatnachticht
    //                H: Versteckte Nachricht
    global $conn, $chat, $http_host, $u_punkte_gesamt, $sms;
    unset($fehler);
    $smszulang = false;
    $emp = user($von_user_id, $userdata, FALSE, FALSE, " ", "", "", FALSE, TRUE);
    $absender = $emp . "@" . $chat . ": ";
    // Wir basteln uns den Absender der SMS
    if (160 - strlen($text) - strlen($absender) < 0) {
        $smszulang = true;
    }
    $text = substr($text, 0, 160 - strlen($absender));
    // Text um Absender kürzen
    $text = preg_replace("/[\\\\" . chr(1) . "-" . chr(31) . "]/", "", $text);
    // Ungültige Zeichen filtern
    $complete = $absender . $text;
    // Prüfen ob genug Punkte
    #if ($u_punkte_gesamt < $sms[punkte]) { $fehler = "Um SMS verschicken zu dürfen brauchst Du mehr als $sms[punkte] Punkte.";}
    // Prüfen ob noch genug SMS-Guthaben da
    $guthaben = hole_smsguthaben($von_user_id);
    if (!isset($fehler)) {
        if ($guthaben <= 0) {
            $fehler = "Du hast kein SMS-Guthaben mehr!";
        }
    }
    // Prüfen ob User SMS möchte
    $query = "SELECT u_sms_ok FROM user WHERE u_id = " . intval($an_user);
    $result = mysql_query($query);
    $a = mysql_fetch_array($result);
    mysql_free_result($result);
    $sms_ok = $a['u_sms_ok'];
    if (!isset($fehler)) {
        if ($sms_ok == "N") {
            $fehler = "Dieser User möchte keine SMS empfangen.";
        }
    }
    // Prüfen auf gültige Handynummer des Empfängers
    $handynr = hole_handynummer($an_user);
    if (!isset($fehler)) {
        if (!pruefe_handynummer($handynr)) {
            $fehler = "Dieser User hat leider keine gültige Handynummer eingetragen.";
        }
    }
    if (isset($fehler)) {
        system_msg("", 0, $von_user_id, $u_farbe, "<b>Fehler:</b> Die SMS konnte nicht verschickt werden. {$fehler}");
    } else {
        $query = "SELECT u_nick FROM user WHERE u_id = " . intval($an_user);
        $result = mysql_query($query);
        $emp2 = mysql_fetch_array($result);
        sms_sende($von_user_id, $an_user, $complete);
        $txt = "<B>{$chat}:</B> sende SMS an {$emp2['u_nick']}: '{$text}'";
        if ($smszulang) {
            system_msg("", 0, $von_user_id, $system_farbe, "<B>Hinweis:</B> Die eingegebene SMS war zu lang. Sie wurde auf 160 Zeichen gekürzt!");
        }
        system_msg("", 0, $von_user_id, $system_farbe, $txt);
    }
    // In Session Timeout-Zeit auf jetzt setzen
    if ($von_user_id) {
        $query = "UPDATE online SET o_timeout_zeit=DATE_FORMAT(NOW(),\"%Y%m%d%H%i%s\"), o_timeout_warnung='N' " . "WHERE o_user=" . intval($von_user_id);
        $result = mysql_query($query, $conn);
    }
    return $back;
}
예제 #2
0
function postings_neu($an_u_id, $u_nick, $id, $nachricht)
{
    global $conn, $t, $system_farbe;
    //schon gelesene Postings des Users holen
    $sql = "select u_gelesene_postings from user where u_id = " . intval($an_u_id);
    $query = mysql_query($sql, $conn);
    if (mysql_num_rows($query) > 0) {
        $gelesene = mysql_result($query, 0, "u_gelesene_postings");
    }
    $u_gelesene = unserialize($gelesene);
    @mysql_free_result($query);
    //alle eigenen Postings des Users mit allen Antworten
    //und dem Threadbaum holen
    //die RegExp matcht auf die Posting-ID im Feld Threadorder
    //entweder mit vorher und nachher keiner Zahl (damit z.B. 32
    //in 131,132,133 nicht matcht) oder am Anfang oder Ende
    //	$sql = "select a.po_id as po_id_own, a.po_th_id as po_th_id,
    //		a.po_titel as po_titel_own,
    //		date_format(from_unixtime(a.po_ts), '%d.%m.%Y %H:%i') as po_date_own,
    //		th_name, fo_name,
    //		b.po_id as po_id_reply, b.po_u_id as po_u_id_reply,
    //		b.po_titel as po_titel_reply,
    //		date_format(from_unixtime(b.po_ts), '%d.%m.%Y %H:%i') as po_date_reply,
    //		u_nick,
    //		c.po_threadorder as threadord, c.po_id as po_id_thread
    //		from posting a, posting b, thema, forum, user
    //		left join posting c on c.po_threadorder REGEXP concat(\"(^|[^0-9])\",a.po_id,\"($|[^0-9])\")
    //		where a.po_u_id = $an_u_id
    //		and a.po_id = b.po_vater_id
    //		and a.po_th_id = th_id
    //		and fo_id=th_fo_id
    //		and b.po_u_id = u_id
    //		and a.po_u_id <> b.po_u_id";
    // Vereinfachter Query ohne Left join, ist nun viel viel schneller. Fehlende Felder werden über zwei weitere Queries gesucht.
    $sql = "\n\t\tselect a.po_id as po_id_own, a.po_th_id as po_th_id,\n\t\ta.po_titel as po_titel_own,\n\t\tdate_format(from_unixtime(a.po_ts), '%d.%m.%Y %H:%i') as po_date_own,\n\t\tth_name, fo_name,\n\t\tb.po_id as po_id_reply, b.po_u_id as po_u_id_reply,\n\t\tb.po_titel as po_titel_reply,\n\t\tdate_format(from_unixtime(b.po_ts), '%d.%m.%Y %H:%i') as po_date_reply,\n\t\tu_nick, a.po_threadorder as threadord, a.po_id as po_id_thread\n\t\tfrom posting a, posting b, thema, forum, user \n\t\twhere a.po_u_id = " . intval($an_u_id) . "\n\t\tand a.po_id = b.po_vater_id \n\t\tand a.po_th_id = th_id \n\t\tand fo_id=th_fo_id \n\t\tand b.po_u_id = u_id \n\t\tand a.po_u_id <> b.po_u_id\n\t\t";
    $query = mysql_query($sql, $conn);
    while ($postings = mysql_fetch_array($query, MYSQL_ASSOC)) {
        //falls posting noch nicht gelesen ist es neu
        if (is_array($u_gelesene[$postings['po_th_id']])) {
            if (!in_array($postings['po_id_reply'], $u_gelesene[$postings['po_th_id']])) {
                $poid = $postings['po_id_own'];
                $postings['po_id_thread'] = suche_vaterposting($poid);
                $postings['threadord'] = suche_threadord($postings['po_id_thread']);
                //Nachricht versenden
                switch ($nachricht) {
                    case "OLM":
                        $text = str_replace("%po_titel%", $postings['po_titel_own'], $t['msg_new_posting_olm']);
                        $text = str_replace("%po_ts%", $postings['po_date_own'], $text);
                        $text = str_replace("%forum%", $postings['fo_name'], $text);
                        $text = str_replace("%thema%", $postings['th_name'], $text);
                        $text = str_replace("%user_from_nick%", $postings['u_nick'], $text);
                        $text = str_replace("%po_titel_antwort%", $postings['po_titel_reply'], $text);
                        $text = str_replace("%po_ts_antwort%", $postings['po_date_reply'], $text);
                        system_msg("", 0, $an_u_id, $system_farbe, $text);
                        break;
                    case "Chat-Mail":
                        if ($postings['threadord']) {
                            $baum = erzeuge_baum($postings['threadord'], $postings['po_id_own'], $postings['po_id_thread']);
                        } else {
                            $baum = $postings['po_titel_own'] . " -> " . $postings['po_titel_reply'];
                        }
                        $betreff = str_replace("%po_titel%", $postings['po_titel_own'], $t['betreff_new_posting']);
                        $text = str_replace("%po_titel%", $postings['po_titel_own'], $t['msg_new_posting_chatmail']);
                        $text = str_replace("%po_ts%", $postings['po_date_own'], $text);
                        $text = str_replace("%forum%", $postings['fo_name'], $text);
                        $text = str_replace("%thema%", $postings['th_name'], $text);
                        $text = str_replace("%user_from_nick%", $postings['u_nick'], $text);
                        $text = str_replace("%po_titel_antwort%", $postings['po_titel_reply'], $text);
                        $text = str_replace("%po_ts_antwort%", $postings['po_date_reply'], $text);
                        $text = str_replace("%baum%", $baum, $text);
                        mail_sende($postings['po_u_id_reply'], $an_u_id, $text, $betreff);
                        break;
                    case "E-Mail":
                        if ($postings['threadord']) {
                            $baum = erzeuge_baum($postings['threadord'], $postings['po_id_own'], $postings['po_id_thread']);
                        } else {
                            $baum = $postings['po_titel_own'] . " -> " . $postings['po_titel_reply'];
                        }
                        $betreff = str_replace("%po_titel%", $postings['po_titel_own'], $t['betreff_new_posting']);
                        $text = str_replace("%po_titel%", $postings['po_titel_own'], $t['msg_new_posting_email']);
                        $text = str_replace("%po_ts%", $postings['po_date_own'], $text);
                        $text = str_replace("%forum%", $postings['fo_name'], $text);
                        $text = str_replace("%thema%", $postings['th_name'], $text);
                        $text = str_replace("%user_from_nick%", $postings['u_nick'], $text);
                        $text = str_replace("%po_titel_antwort%", $postings['po_titel_reply'], $text);
                        $text = str_replace("%po_ts_antwort%", $postings['po_date_reply'], $text);
                        $text = str_replace("%baum%", $baum, $text);
                        email_versende($postings['po_u_id_reply'], $an_u_id, $text, $betreff);
                        break;
                    case "SMS":
                        $text = str_replace("%po_titel%", $postings['po_titel_own'], $t['msg_new_posting_sms']);
                        $text = str_replace("%po_ts%", $postings['po_date_own'], $text);
                        $text = str_replace("%forum%", $postings['fo_name'], $text);
                        $text = str_replace("%thema%", $postings['th_name'], $text);
                        sms_sende($an_u_id, $an_u_id, $text);
                        break;
                }
            }
        }
        // endif is_array
    }
    @mysql_free_result($query);
}