Seite 1 von 1

"Einlogwarnung"

Verfasst: 16.01.2004 02:43
von mscholz
Hallo Forum!

Gibt es eine Möglichkeit eine Mail (oder PM) an einen Moderator oder Administrator zu schicken, wenn sich ein bestimmter User einloggt?

Mirko

Verfasst: 17.01.2004 01:44
von Acid

Code: Alles auswählen

$sql2 = "SELECT session_user_id, session_start, user_id
	FROM ". SESSIONS_TABLE .", ". USERS_TABLE ."
	WHERE session_user_id = user_id";
if( !($result = $db->sql_query($sql2)) )
{
	message_die(GENERAL_ERROR, 'Could not get session_user_id.', '', __LINE__, __FILE__, $sql2);
}
if( $row2 = $db->sql_fetchrow($result2) );
{
        if( $row2['user_id'] == '3' && $row2['session_start'] == time() )
        {
                mail('deine@adresse.de','hi','hi. this is a test','From: '. $board_config['board_email'].'');
        } 
}
..trag das mal testweise in der index.php vor $template->pparse('body'); ein (deine@adresse.de mit einer gültigen mail-Adresse ersetzen und bei '3' die ID des Users eintragen).
(Eventueller Haken bei der Sache, du bekommst öfters Mails... Mir fällt jetzt momentan nix ein, wie man den Login des Users sonst herausfinden kann. )

Verfasst: 17.01.2004 14:45
von mscholz
mhhh, vielen Dank für die Hilfe. Leider funktioniert es nicht.

Ich bekomme gar keine Mail. Die Seite läd normal. Hab auch schon geguckt, ob was bounced und verschiedene eMail Adresse probiert. Und hab auch schon meine eigene User ID (2, nehme ich an) eingetragen.

Ist vielleicht hier nen Fehler?

mail('deine@adresse.de','hi','hi. this is a test','From: '. $board_config['board_email'].'');

denn, Du hast nen From: aber kein Subject: oder To:?

Mirko

Verfasst: 17.01.2004 15:05
von Acid
..is nur ´n simples mail()-Script, vielleicht zu simple. ;) (Ich hatte jetzt ka Bock das ganze emailer Zeugs zu posten.) Ersetze mal die mail() Zeile mit folgendem (trage bei $id_sender und $id_resv deine ID ein)..

Code: Alles auswählen

	        $id_sender = '2'; 
	        $id_resv = '2'; 
	        $msg_time = time(); 
	        $pm_subject = 'titel'; 
	        $pm_text = 'text'; 
	        $bbcode_uid = '';
          
	        $sql = "INSERT INTO " . PRIVMSGS_TABLE . " (privmsgs_type, privmsgs_subject, privmsgs_from_userid, privmsgs_to_userid, privmsgs_date, privmsgs_ip, privmsgs_enable_html, privmsgs_enable_bbcode, privmsgs_enable_smilies, privmsgs_attach_sig) 
	                VALUES (" . PRIVMSGS_NEW_MAIL . ", '" . str_replace("\'", "''", $pm_subject) . "', " . $id_sender . ", " . $id_resv . ", $msg_time, '7f000001', 1, 1, 1, 0)"; 
	        if ( !($result = $db->sql_query($sql, BEGIN_TRANSACTION)) ) 
	        { 
	                message_die(GENERAL_ERROR, "Could not insert/update private message sent info.", "", __LINE__, __FILE__, $sql_info); 
	        } 
          
	        $privmsg_sent_id = $db->sql_nextid(); 
	        $sql = "INSERT INTO " . PRIVMSGS_TEXT_TABLE . " (privmsgs_text_id, privmsgs_bbcode_uid, privmsgs_text) 
	                VALUES ($privmsg_sent_id, '". $bbcode_uid ."', '" . str_replace("\'", "''", addslashes($pm_text)) . "')";
	        if ( !$db->sql_query($sql, END_TRANSACTION) ) 
	        { 
	                message_die(GENERAL_ERROR, "Could not insert/update private message sent text.", "", __LINE__, __FILE__, $sql_info); 
	        } 
          
	        $sql = "UPDATE " . USERS_TABLE . " SET user_new_privmsg = user_new_privmsg + 1, user_last_privmsg = " . time() . "  
	                WHERE user_id = " . $id_resv; 
	        if ( !$status = $db->sql_query($sql) ) 
	        { 
	                message_die(GENERAL_ERROR, 'Could not update private message new/read status for user', '', __LINE__, __FILE__, $sql); 
	        } 

Verfasst: 17.01.2004 17:10
von mscholz
mist, will nicht. bekomme nichts, auch keinen fehler, obwohl ich reloads gemacht habe und user 119 sich eingeloggt hat.

ich hab:

Code: Alles auswählen

//
// Remove me!
//

$sql2 = "SELECT session_user_id, session_start, user_id
   FROM ". SESSIONS_TABLE .", ". USERS_TABLE ."
   WHERE session_user_id = user_id";
if( !($result = $db->sql_query($sql2)) )
{
   message_die(GENERAL_ERROR, 'Could not get session_user_id.', '', __LINE__, __FILE__, $sql2);
}
if( $row2 = $db->sql_fetchrow($result2) );
{
        if( $row2['user_id'] == '119' && $row2['session_start'] == time() )
        {
                
           $id_sender = '2';
           $id_resv = '2';
           $msg_time = time();
           $pm_subject = 'Player is on!';
           $pm_text = 'The Player is on!';
           $bbcode_uid = '';
         
           $sql = "INSERT INTO " . PRIVMSGS_TABLE . " (privmsgs_type, privmsgs_subject, privmsgs_from_userid, privmsgs_to_userid, privmsgs_date, privmsgs_ip, privmsgs_enable_html, privmsgs_enable_bbcode, privmsgs_enable_smilies, privmsgs_attach_sig)
                   VALUES (" . PRIVMSGS_NEW_MAIL . ", '" . str_replace("\'", "''", $pm_subject) . "', " . $id_sender . ", " . $id_resv . ", $msg_time, '7f000001', 1, 1, 1, 0)";
           if ( !($result = $db->sql_query($sql, BEGIN_TRANSACTION)) )
           {
                   message_die(GENERAL_ERROR, "Could not insert/update private message sent info.", "", __LINE__, __FILE__, $sql_info);
           }
         
           $privmsg_sent_id = $db->sql_nextid();
           $sql = "INSERT INTO " . PRIVMSGS_TEXT_TABLE . " (privmsgs_text_id, privmsgs_bbcode_uid, privmsgs_text)
                   VALUES ($privmsg_sent_id, '". $bbcode_uid ."', '" . str_replace("\'", "''", addslashes($pm_text)) . "')";
           if ( !$db->sql_query($sql, END_TRANSACTION) )
           {
                   message_die(GENERAL_ERROR, "Could not insert/update private message sent text.", "", __LINE__, __FILE__, $sql_info);
           }
         
           $sql = "UPDATE " . USERS_TABLE . " SET user_new_privmsg = user_new_privmsg + 1, user_last_privmsg = " . time() . " 
                   WHERE user_id = " . $id_resv;
           if ( !$status = $db->sql_query($sql) )
           {
                   message_die(GENERAL_ERROR, 'Could not update private message new/read status for user', '', __LINE__, __FILE__, $sql);
           }





        }
}
und das vor:

Code: Alles auswählen

//
// Generate the page
//

$template->pparse('body');

include($phpbb_root_path . 'includes/page_tail.'.$phpEx);