k hier schonmal die erste datei
Code: Alles auswählen
<?php
function get_congrat_config()
{
global $db, $board_config;
$congrat_config = array();
$sql = "SELECT *
FROM " . CONGRATS_TABLE;
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not query Congratulation information', '', __LINE__, __FILE__, $sql);
}
while ($row = $db->sql_fetchrow($result))
{
$congrat_config[$row['config_name']] = trim($row['config_value']);
}
return ($congrat_config);
}
$congrat_config = get_congrat_config();
$congrat_array = array($congrat_config['congrat_posts']);
$do_congrat = (in_array($userdata['user_posts'], ($congrat_array)) && ( $userdata['user_congrat'] < $userdata['user_posts'] )) ? TRUE : FALSE ;
if ( !$congrat_config['congrat_active'] == 0 && !$userdata['session_logged_in'] == 0 )
{
if ( $congrat_config['congrat_when'] == 1 )
{
$sql = "SELECT user_id, user_posts, user_congrat
FROM " . USERS_TABLE . "
WHERE user_id = " . $userdata['user_id'];
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not get user posts', '', __LINE__, __FILE__, $sql);
}
if ( in_array($userdata['user_posts'], ($congrat_array)) && ( $userdata['user_congrat'] < $userdata['user_posts'] ) )
{
$sql = "UPDATE " . USERS_TABLE . "
SET user_congrat = ".$userdata['user_posts']."
WHERE user_id = " . $userdata['user_id'];
if ( !$db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not update users table', '', __LINE__, __FILE__, $sql);
}
else
{
if ( !$congrat_config['congrat_how'] == 0 )
{
$template->assign_var("CONGRAT_POPUP",
"<script language=\"Javascript\" type=\"text/javascript\"><!--
window.open('".append_sid('congrat_popup.'.$phpEx)."', '_phpbbprivmsg', 'HEIGHT=225,resizable=yes,WIDTH=400');
//-->
</script>");
}
else
{
$congrat_message = sprintf($congrat_config['congrat_text'], $userdata['username'], $userdata['user_posts']);
$template->assign_block_vars("congrat_user", array());
$template->assign_var("CONGRAT_MESSAGE",$congrat_message);
}
}
}
}
else
{
$sql = "SELECT SUM(forum_posts) AS post_total
FROM " . FORUMS_TABLE;
if ( !($result = $db->sql_query($sql)) )
{
return false;
}
$row = $db->sql_fetchrow($result);
}
$post_total = $row['post_total'];
if ( in_array($row['post_total'], ($congrat_array)) )
{
$sql = "UPDATE " . CONGRATS_TABLE . "
SET config_value = " . $userdata['user_id'] . "
WHERE config_name = 'congrat_usersumid'";
if ( !$db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not congrats congrats table', '', __LINE__, __FILE__, $sql);
}
else
{
$sql = "UPDATE " . CONGRATS_TABLE . "
SET config_value = " . $row['post_total'] . "
WHERE config_name = 'congrat_reached'";
if (!$db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Could not update congrat table', '', __LINE__, __FILE__, $sql);
}
else
{
$sql = "UPDATE " . USERS_TABLE . "
SET user_congrat = ".$userdata['user_posts']."
WHERE user_id = " . $userdata['user_id'];
if ( !$db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not update users table', '', __LINE__, __FILE__, $sql);
}
else
{
if ( $do_congrat == TRUE )
{
if ( !$congrat_config['congrat_how'] == 0 )
{
$template->assign_var("CONGRAT_POPUP",
"<script language=\"Javascript\" type=\"text/javascript\"><!--
window.open('".append_sid('congrat_popup.'.$phpEx)."', '_phpbbprivmsg', 'HEIGHT=225,resizable=yes,WIDTH=400');
//-->
</script>");
}
else
{
$congrat_message = sprintf($congrat_config['congrat_text'], $userdata['username'], $congrat_config['congrat_reached']);
$template->assign_block_vars("congrat_user", array());
$template->assign_var("CONGRAT_MESSAGE",$congrat_message);
}
}
}
}
}
}
}
?>
und hier das popup dazu
Code: Alles auswählen
<?
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
//
// End session management
//
$gen_simple_header = TRUE;
$page_title = $lang['Congrat_title'];
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
$sql = "SELECT *
FROM " . CONGRATS_TABLE;
if( !($result = $db->sql_query($sql)) )
{
message_die(CRITICAL_ERROR, "Could not query congrat information", "", __LINE__, __FILE__, $sql);
}
while ( $row = $db->sql_fetchrow($result) )
{
$congrat[$row['config_name']] = $row['config_value'];
}
if ( !$congrat['congrat_when'] == 1 )
{
$sql = "SELECT username
FROM " . USERS_TABLE . "
WHERE user_id = ". $congrat['congrat_usersumid'];
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not get user data', '', __LINE__, __FILE__, $sql);
}
$row = $db->sql_fetchrow($result);
$l_congrat_user = sprintf($congrat['congrat_text'], $row['username'], $congrat['congrat_reached']);
}
else
{
$sql = "SELECT username, user_posts
FROM " . USERS_TABLE . "
WHERE user_id = ". $userdata['user_id'] . "
AND user_congrat = ".$userdata['user_posts'] ;
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not get user data', '', __LINE__, __FILE__, $sql);
}
$row = $db->sql_fetchrow($result);
$l_congrat_user = sprintf($congrat['congrat_text'], $row['username'], $row['user_posts']);
}
$template->set_filenames(array(
'body' => 'congrat_popup.tpl'));
$template->assign_vars(array(
'L_CLOSE_WINDOW' => $lang['Close_window'],
'L_MESSAGE' => $l_congrat_user));
$template->pparse('body');
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
?>
Nichts auf der welt ist so gerecht verteilt wie der Verstand.Denn jederman ist überzeugt das er genug davon habe.