function aktion_sofort($po_id, $po_vater_id, $thread)
{
    global $conn, $t;
    //aktionen nur fuer Antworten
    if ($po_vater_id > 0) {
        $sql = "select po_u_id, date_format(from_unixtime(po_ts), '%d.%m.%Y') as po_date, po_titel,\n\t\t\tth_name, fo_name \n\t\t\tfrom posting, thema, forum\n\t\t\twhere po_id = " . intval($po_vater_id) . "\n\t\t\tand po_th_id = th_id\n\t\t\tand th_fo_id = fo_id";
        $query = mysql_query($sql, $conn);
        if ($query && mysql_num_rows($query) > 0) {
            //Daten des Vaters holen
            $user = mysql_result($query, 0, "po_u_id");
            $po_ts = mysql_result($query, 0, "po_date");
            $po_titel = mysql_result($query, 0, "po_titel");
            $thema = mysql_result($query, 0, "th_name");
            $forum = mysql_result($query, 0, "fo_name");
            @mysql_free_result($query);
        } else {
            return;
        }
        $sql = "select u_id, u_nick, \n\t\t\tdate_format(from_unixtime(po_ts), '%d.%m.%Y %H:%i') as po_date, po_titel  \n\t\t\tfrom user, posting \n\t\t\twhere po_u_id = u_id \n\t\t\tand po_id = " . intval($po_id);
        $query = mysql_query($sql, $conn);
        if ($query && mysql_num_rows($query) > 0) {
            $user_from_id = mysql_result($query, 0, "u_id");
            $user_from_nick = mysql_result($query, 0, "u_nick");
            $po_ts_antwort = mysql_result($query, 0, "po_date");
            $po_titel_antwort = mysql_result($query, 0, "po_titel");
            @mysql_free_result($query);
        } else {
            return;
        }
        //Ist betroffener User Online?
        $online = ist_online($user);
        if ($online) {
            $wann = "Sofort/Online";
        } else {
            $wann = "Sofort/Offline";
        }
        //Threadorder fuer diesen Thread holen
        $sql = "select po_threadorder \n\t\t\tfrom posting \n\t\t\twhere po_id=" . intval($thread);
        $query = mysql_query($sql, $conn);
        if ($query && mysql_num_rows($query) == 1) {
            $threadorder = mysql_result($query, 0, "po_threadorder");
        } else {
            return;
        }
        $baum = erzeuge_baum($threadorder, $po_id, $thread);
        $text['po_titel'] = $po_titel;
        $text['po_ts'] = $po_ts;
        $text['forum'] = $forum;
        $text['thema'] = $thema;
        $text['user_from_nick'] = $user_from_nick;
        $text['po_titel_antwort'] = $po_titel_antwort;
        $text['po_ts_antwort'] = $po_ts_antwort;
        $text['baum'] = $baum;
        aktion($wann, $user, $user_from_id, "", "Antwort auf eigenes Posting", $text);
    }
}
Exemplo n.º 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);
}