| |
Avant toute installation de ce mod, il est fortement conseillé de faire une sauvegarde des fichiers à modifier ainsi qu'une sauvegarde de votre base de données.
Ce n'est pas un mod mais une fonction, qui permet d'envoyer des message dans un forum spécifique, facile d'utilisation.. Elle peut aider quelques personnes mais elle est moins bien que celle de wGEric... Pour l'utiliser, à vous de créer la page qui fera appel à insert_post() avec ses paramètres.
1 0 1
01 40 13 05 2006
09 08 17 05 2006
function insert_post($ forum_id , $ topic_title , $ post_message )
{
global $ board_config , $ lang , $ db , $ phpbb_root_path , $ phpEx ;
global $ userdata , $ user_ip ;
include_once($ phpbb_root_path . ' includes/bbcode. ' . $ phpEx );
include_once($ phpbb_root_path . ' includes/functions_post. ' . $ phpEx );
$ bbcode_uid = make_bbcode_uid();
$ html_on = ($ board_config [ ' allow_html ' ] ! = 0) ? $ board_config [ ' allow_html ' ] : $ userdata [ ' user_allowhtml ' ] ;
$ bbcode_on = ($ board_config [ ' allow_bbcode ' ] ! = 0) ? $ board_config [ ' allow_bbcode ' ] : $ userdata [ ' user_allowbbcode ' ] ;
$ smilies_on = ($ board_config [ ' allow_smilies ' ] ! = 0) ? $ board_config [ ' allow_smilies ' ] : $ userdata [ ' user_allowsmile ' ] ;
$ post_message = prepare_message($ post_message , $ html_on , $ bbcode_on , $ smilies_on , $ bbcode_uid );
$ time = time();
$ user = $ userdata [ ' user_id ' ] ;
$ sql = ' INSERT INTO ' . TOPICS_TABLE . " ( topic_title , topic_poster , topic_time , forum_id , topic_status , topic_type , topic_vote ) VALUES ( ' $ topic_title ' , ' 1 ' , ' $ time ' , $ forum_id , " . TOPIC_UNLOCKED . " , 0 , 0 ) " ;
if (! $db ->sql_query ($ sql ))
{
message_die(GENERAL_ERROR, ' Error in posting ' , ' ' , __LINE__ , __FILE__ , $ sql );
}
$ topic_id = $db ->sql_nextid ();
$ sqls = ' INSERT INTO ' . POSTS_TABLE . " ( topic_id , forum_id , poster_id , post_username , post_time , poster_ip , enable_bbcode , enable_html , enable_smilies , enable_sig ) VALUES ( $ topic_id , $ forum_id , ' 1 ' , ' ' , $ time , ' $ user_ip ' , 1 , 0 , 1 , 1 ) " ;
if (! $db ->sql_query ($ sqls , BEGIN_TRANSACTION))
{
message_die(GENERAL_ERROR, ' Error in posting ' , ' ' , __LINE__ , __FILE__ , $ sqls );
}
$ post_id = $db ->sql_nextid ();
$ sqlz = ' INSERT INTO ' . POSTS_TEXT_TABLE . " ( post_id , post_subject , bbcode_uid , post_text ) VALUES ( $ post_id , ' $ topic_title ' , ' $ bbcode_uid ' , ' $ post_message ' ) " ;
if (! $db ->sql_query ($ sqlz ))
{
message_die(GENERAL_ERROR, ' Error in posting ' , ' ' , __LINE__ , __FILE__ , $ sqlz );
}
$ forum_update_sql = ' forum_last_post_id = ' . $ post_id . ' , forum_topics = forum_topics +1, forum_posts = forum_posts + 1 ' ;
$ sqls = ' UPDATE ' . FORUMS_TABLE . ' SET ' . $ forum_update_sql . ' WHERE forum_id = ' . $ forum_id ;
if (! $db ->sql_query ($ sqls ))
{
message_die(GENERAL_ERROR, ' Error in posting ' , ' ' , __LINE__ , __FILE__ , $ sqls );
}
$ sqla = ' UPDATE ' . USERS_TABLE . ' SET user_posts = user_posts +1 WHERE user_id = 1 ' ;
if (! $db ->sql_query ($ sqla , END_TRANSACTION))
{
message_die(GENERAL_ERROR, ' Error in posting ' , ' ' , __LINE__ , __FILE__ , $ sqla );
}
include($ phpbb_root_path . ' includes/functions_admin. ' . $ phpEx );
sync(' topic ' , $ topic_id );
return ;
}
|
|
| |
Avant toute installation de ce mod, il est fortement conseillé de faire une sauvegarde des fichiers à modifier ainsi qu'une sauvegarde de votre base de données.
Ce n'est pas un mod mais une fonction, qui permet d'envoyer des MP, facile d'utilisation... Elle peut aider quelques personnes mais elle est moins bien que celle de wGEric... Pour l'utiliser, à vous de créer la page qui fera appel à send_mp().
<?php
1 0 0
function quote_smarts($ value )
{
if (get_magic_quotes_gpc())
{
$ value = stripslashes($ value );
}
if (! is_numeric($ value ))
{
$ value = " ' " . mysql_real_escape_string($ value ) . " ' " ;
}
return $ value ;
}
1 3 7
01 40 13 05 2006
16 55 01 10 2006
if ( ! function_exists( ' send_pm ' ) )
{
function send_pm($ to , $ subject , $ text , $ from = ' ' )
{
global $ board_config , $ lang , $ db , $ phpbb_root_path , $ phpEx ;
global $ userdata , $ user_ip ;
include_once($ phpbb_root_path . ' includes/bbcode. ' . $ phpEx );
include_once($ phpbb_root_path . ' includes/functions_post. ' . $ phpEx );
$ sqlaaa = ' SELECT user_id, user_notify_pm, user_email, user_lang, user_active, user_allowhtml, user_allowsmile, user_allowbbcode, user_attachsig FROM ' . USERS_TABLE . ' WHERE user_id = ' . $ to . ' AND user_id <> ' . ANONYMOUS. ' ; ' ;
if ( ! ($ result = $db ->sql_query ($ sqlaaa )) )
{
message_die(GENERAL_ERROR, ' Could not select users table ' , ' ' , __LINE__ , __FILE__ , $ sqlaaa );
}
$ to_userdata = $db ->sql_fetchrow ($ result );
if ( ! $ from )
{
$ from = $ userdata [ ' user_id ' ] ;
}
$ uid = make_bbcode_uid();
$ date = date(' U ' );
$ html_on = ($ board_config [ ' allow_html ' ] ! = 0 ) ? $ board_config [ ' allow_html ' ] : $ to_userdata [ ' user_allowhtml ' ] ;
$ smilies_on = ($ board_config [ ' allow_smilies ' ] ! = 0 ) ? $ board_config [ ' allow_smilies ' ] : $ to_userdata [ ' user_allowsmile ' ] ;
$ bbcode_on = ($ board_config [ ' allow_bbcode ' ] ! = 0 ) ? $ board_config [ ' allow_bbcode ' ] : $ to_userdata [ ' user_allowbbcode ' ] ;
$ attach_sig = $ to_userdata [ ' user_attachsig ' ] ;
$ text = prepare_message($ text , $ html_on , $ bbcode_on , $ smilies_on , $ uid );
$ sqlf = ' SELECT COUNT(privmsgs_id) AS inbox_items, MIN(privmsgs_date) AS oldest_post_time
FROM ' . PRIVMSGS_TABLE . '
WHERE ( privmsgs_type = ' . PRIVMSGS_NEW_MAIL . '
OR privmsgs_type = ' . PRIVMSGS_READ_MAIL . '
OR privmsgs_type = ' . PRIVMSGS_UNREAD_MAIL . ' )
AND privmsgs_to_userid = ' . $ to_userdata [ ' user_id ' ] . ' ; ' ;
if ( ! ($ result = $db ->sql_query ($ sqlf )) )
{
message_die(GENERAL_ERROR, ' Could not find max privmsgs (inbox) ' , ' ' , __LINE__ , __FILE__ , $ sqlf );
}
$ sql_priority = ( SQL_LAYER = = ' mysql ' ) ? ' LOW_PRIORITY ' : ' ' ;
if ( $ inbox_info = $db ->sql_fetchrow ($ result ) )
{
if ( $ inbox_info [ ' inbox_items ' ] > = $ board_config [ ' max_inbox_privmsgs ' ] )
{
$ sqlk = ' SELECT privmsgs_id FROM ' . PRIVMSGS_TABLE . '
WHERE ( privmsgs_type = ' . PRIVMSGS_NEW_MAIL . '
OR privmsgs_type = ' . PRIVMSGS_READ_MAIL . '
OR privmsgs_type = ' . PRIVMSGS_UNREAD_MAIL . ' )
AND privmsgs_date = ' . $ inbox_info [ ' oldest_post_time ' ] . '
AND privmsgs_to_userid = ' . $ to_userdata [ ' user_id ' ] . ' ; ' ;
if ( ! $ result = $db ->sql_query ($ sqlk ) )
{
message_die(GENERAL_ERROR, ' Could not find oldest privmsgs (inbox) ' , ' ' , __LINE__ , __FILE__ , $ sqlk );
}
$ old_privmsgs_id = $db ->sql_fetchrow ($ result );
$ old_privmsgs_id = $ old_privmsgs_id [ ' privmsgs_id ' ] ;
$ sqll = ' DELETE ' . $ sql_priority . ' FROM ' . PRIVMSGS_TABLE . ' WHERE privmsgs_id = ' . $ old_privmsgs_id . ' ; ' ;
if ( ! $db ->sql_query ($ sqll ) )
{
message_die(GENERAL_ERROR, ' Could not delete oldest privmsgs (inbox) ' . $ sql , ' ' , __LINE__ , __FILE__ , $ sqll );
}
$ sqlm = ' DELETE ' . $ sql_priority . ' FROM ' . PRIVMSGS_TEXT_TABLE . ' WHERE privmsgs_text_id = ' . $ old_privmsgs_id . ' ; ' ;
if ( ! $db ->sql_query ($ sqlm ) )
{
message_die(GENERAL_ERROR, ' Could not delete oldest privmsgs text (inbox) ' , ' ' , __LINE__ , __FILE__ , $ sqlm );
}
}
}
$ sqly = ' UPDATE ' . USERS_TABLE . " SET user_new_privmsg = user_new_privmsg + 1 , user_last_privmsg = $ date WHERE user_id = $ to ; " ;
if ( ! ($ result = $db ->sql_query ($ sqly )) )
{
message_die(GENERAL_ERROR, ' Could not update users table ' , ' ' , __LINE__ , __FILE__ , $ sqly );
}
$ sqlq = sprintf(' 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 (%s, %s, %s, %s, %s, "%s", %s, %s, %s, %s); ' ,
PRIVMSGS_NEW_MAIL , quote_smarts(trim(strip_tags($ subject ))), $ from , $ to , $ date , $ user_ip , $ html_on , $ bbcode_on , $ smilies_on , $ attach_sig );
if ( ! ($ result = $db ->sql_query ($ sqlq )) )
{
message_die(GENERAL_ERROR, ' Could not insert private message sent info ' , ' ' , __LINE__ , __FILE__ , $ sql );
}
$ privmsg_sent_id = $db ->sql_nextid ();
$ sqls = sprintf(' INSERT INTO ' . PRIVMSGS_TEXT_TABLE . ' (privmsgs_text_id, privmsgs_bbcode_uid, privmsgs_text) VALUES (%s, %s, %s); ' ,
$ privmsg_sent_id , quote_smarts($ uid ), quote_smarts(sprintf($ text , $ board_config [ ' sitename ' ] )));
if ( ! ($ result = $db ->sql_query ($ sqls )) )
{
message_die(GENERAL_ERROR, ' Could not insert private message sent text ' , ' ' , __LINE__ , __FILE__ , $ sql );
}
return ;
}
}
?>
|
|
Consultez les autres pages sources
|
|