the following thing is driving me TOTALLY crazy, because i cant solve it...
i have rewritten a free tournament script to fully work with ICY users, functions and so on... all is working fine, as it should... but one small thing not...
the following code is from the tourney start page... if the admin start the tourney, all users should receive a PM with further details... its the first part of the code in the file... (rejected == 0)
and if there is a user with rejected == 1 (the else part) he should get a different PM wich tells him that he cant participate in the tourney...
The problem is... the script is sending all messages corretly for the first part... but not for the one user (and of course there is 1 user) with rejected == 1...
I also commented the first part, to check that there isn´t a problem with the second part... and then the 1 PM for this user is sended correctly...
anyone out here to help me solving this problem?
Spoiler: [ Show ]
Spoiler: [ Hide ]
<?php
// access for headadmins only
if ($user['usertype_headadmin'])
{
if ($season['status'] == 'running')
{
$message = $lang['T_TOURNEY_RUNNING'];
}
elseif ($season['status'] == 'finished')
{
$message = $lang['T_TOURNEY_FINISHED'];
}
elseif ($season['status'] != 'bracket')
{
$message = $lang['T_SET_BRACKET_FIRST'];
}
else
{
// season users-query
$sql = "SELECT * FROM " . TOURNEY_SEASON_USERS_TABLE . "
WHERE `id_season` = " . $_REQUEST['season_id'] . "
AND `usertype_player` = 1";
if ( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not obtain tourney season users information.', '', __LINE__, __FILE__, $sql);
}
$season_users_row = $db->sql_fetchrow($result);
$script_name = preg_replace('/^\/?(.*?)\/?$/', "\1", trim($board_config['script_path']));
$script_name = ($script_name != '') ? $script_name . '/tourney.' . PHP_EXT : 'tourney.' . PHP_EXT;
$server_name = trim($board_config['server_name']);
$server_protocol = ($board_config['cookie_secure']) ? 'https://' : 'http://';
$server_port = ($board_config['server_port'] <> 80) ? ':' . trim($board_config['server_port']) . '/' : '/';
$url_tourney_adress = $server_protocol . $server_name . $server_port . $script_name . '?season_id=' . $_REQUEST['season_id'];
// send a mail to all player that signed up
// if player is not rejected
if ($season_users_row['rejected'] == 0)
{
// This Query is needed to get the player names to PM ...
$sql2 = "SELECT u1.username AS username_1, u1.user_id AS user_id_1, u1.user_active AS user_active_1, u2.username AS username_2, u2.user_id AS user_id_2, u2.user_active AS user_active_2, m.*
FROM " . USERS_TABLE . " u1, " . USERS_TABLE . " u2, " . TOURNEY_MATCHES_TABLE . " m
WHERE m.id_player1 = u1.user_id
AND m.id_player2 = u2.user_id
AND m.id_season = " . $_REQUEST['season_id'] . "";
if (!($result2 = $db->sql_query($sql2)))
{
message_die(GENERAL_ERROR, 'Could not query private message post information', '', __LINE__, __FILE__, $sql2);
}
$user_n_row = $db->sql_fetchrowset($result2);
for ($x = 0; $x < count($user_n_row); $x++)
{
if ($user_n_row[$x]['user_active_1'])
{
$player_id = $user_n_row[$x]['user_id_1'];
$player_username = $user_n_row[$x]['username_1'];
$opponent_id = $user_n_row[$x]['user_id_2'];
$opponent_username = $user_n_row[$x]['username_2'];
$bracket = $user_n_row[$x]['bracket'];
$round = $user_n_row[$x]['round'];
$match = $user_n_row[$x]['match'];
$round_pre = $round - 1;
$round_post = $round;
$sql3 = "SELECT * FROM " . TOURNEY_DEADLINES_TABLE . "
WHERE `id_season` = '" . $_REQUEST['season_id'] . "'
AND `round` = '" . $bracket . $round_pre . "'";
if ( !$result3 = $db->sql_query($sql3) )
{
message_die(GENERAL_ERROR, 'Could not obtain tourney deadlines information.', '', __LINE__, __FILE__, $sql3);
}
$deadlines_ref1 = $db->sql_numrows($result3);
if ( $deadlines_row1 = $db->sql_fetchrow($result3) )
{
$deadline_pre = create_date($board_config['default_dateformat'], $deadlines_row1['deadline'], $board_config['board_timezone']);
}
$sql4 = "SELECT * FROM " . TOURNEY_DEADLINES_TABLE . "
WHERE `id_season` = '" . $_REQUEST['season_id'] . "'
AND `round` = '" . $bracket . $round_post . "'";
if ( !$result4 = $db->sql_query($sql4) )
{
message_die(GENERAL_ERROR, 'Could not obtain tourney deadlines information.', '', __LINE__, __FILE__, $sql4);
}
$deadlines_ref2 = $db->sql_numrows($result4);
if ( $deadlines_row2 = $db->sql_fetchrow($result4) )
{
$deadline_post = create_date($board_config['default_dateformat'], $deadlines_row2['deadline'], $board_config['board_timezone']);
}
$url_tourney = '[url=' . $url_tourney_adress . ']' . $url_tourney_adress . '[/url]';
$pm_subject = $lang['T_MATCH_NOTIFY'] . ' - ' . $section['name'] . ' - ' . $season['name'];
$pm_text = sprintf($lang['T_MATCH_NOTIFY_TEXT'], $player_username, $bracket, $round, $match, $section['name'], $season['name'], $opponent_username, $deadline_pre, $deadline_post, $url_tourney, ip_stripslashes($board_config['sitename']));
// PM - BEGIN
$founder_id = (defined('FOUNDER_ID') ? FOUNDER_ID : get_founder_id());
include_once(IP_ROOT_PATH . 'includes/class_pm.' . PHP_EXT);
$privmsg_sender = $founder_id;
$privmsg_recipient = $player_id;
$privmsg_subject = $pm_subject;
$privmsg_message = $pm_text;
$privmsg = new class_pm();
$privmsg->send($privmsg_sender, $privmsg_recipient, $privmsg_subject, $privmsg_message);
unset($privmsg);
// PM - END
}
if ($user_n_row[$x]['user_active_2'])
{
$player_id = $user_n_row[$x]['user_id_2'];
$player_username = $user_n_row[$x]['username_2'];
$opponent_id = $user_n_row[$x]['user_id_1'];
$opponent_username = $user_n_row[$x]['username_1'];
$bracket = $user_n_row[$x]['bracket'];
$round = $user_n_row[$x]['round'];
$match = $user_n_row[$x]['match'];
$round_pre = $round - 1;
$round_post = $round;
$sql5 = "SELECT * FROM " . TOURNEY_DEADLINES_TABLE . "
WHERE `id_season` = '" . $_REQUEST['season_id'] . "'
AND `round` = '" . $bracket . $round_pre . "'";
if ( !$result5 = $db->sql_query($sql5) )
{
message_die(GENERAL_ERROR, 'Could not obtain tourney deadlines information.', '', __LINE__, __FILE__, $sql5);
}
$deadlines_ref1 = $db->sql_numrows($result5);
if ( $deadlines_row1 = $db->sql_fetchrow($result5) )
{
$deadline_pre = create_date($board_config['default_dateformat'], $deadlines_row1['deadline'], $board_config['board_timezone']);
}
$sql6 = "SELECT * FROM " . TOURNEY_DEADLINES_TABLE . "
WHERE `id_season` = '" . $_REQUEST['season_id'] . "'
AND `round` = '" . $bracket . $round_post . "'";
if ( !$result6 = $db->sql_query($sql6) )
{
message_die(GENERAL_ERROR, 'Could not obtain tourney deadlines information.', '', __LINE__, __FILE__, $sql6);
}
$deadlines_ref2 = $db->sql_numrows($result6);
if ( $deadlines_row2 = $db->sql_fetchrow($result6) )
{
$deadline_post = create_date($board_config['default_dateformat'], $deadlines_row2['deadline'], $board_config['board_timezone']);
}
$url_tourney = '[url=' . $url_tourney_adress . ']' . $url_tourney_adress . '[/url]';
$pm_subject = $lang['T_MATCH_NOTIFY'] . ' - ' . $section['name'] . ' - ' . $season['name'];
$pm_text = sprintf($lang['T_MATCH_NOTIFY_TEXT'], $player_username, $bracket, $round, $match, $section['name'], $season['name'], $opponent_username, $deadline_pre, $deadline_post, $url_tourney, ip_stripslashes($board_config['sitename']));
// PM - BEGIN
$founder_id = (defined('FOUNDER_ID') ? FOUNDER_ID : get_founder_id());
include_once(IP_ROOT_PATH . 'includes/class_pm.' . PHP_EXT);
$privmsg_sender = $founder_id;
$privmsg_recipient = $player_id;
$privmsg_subject = $pm_subject;
$privmsg_message = $pm_text;
$privmsg = new class_pm();
$privmsg->send($privmsg_sender, $privmsg_recipient, $privmsg_subject, $privmsg_message);
unset($privmsg);
// PM - END
}
}
}
// send a mail to the players that cant participate
// if player is rejected
else
{
// This Query is needed to get the player names to PM ...
$sql7 = "SELECT * FROM " . USERS_TABLE . "
WHERE user_id = '" . $season_users_row['id_user'] . "'";
if (!($result7 = $db->sql_query($sql7)))
{
message_die(GENERAL_ERROR, 'Could not obtain users information', '', __LINE__, __FILE__, $sql7);
}
$user_row = $db->sql_fetchrowset($result7);
for ($y = 0; $y < count($user_row); $y++)
{
$player_id = $user_row[$y]['user_id'];
$player_username = $user_row[$y]['username'];
$url_tourney = '[url=' . $url_tourney_adress . ']' . $url_tourney_adress . '[/url]';
$pm_subject = sprintf($lang['T_MATCH_NOTIFY_OUT'], $section['name'], $season['name']);
$pm_text = sprintf($lang['T_MATCH_NOTIFY_TEXT_OUT'], $player_username, $section['name'], $season['name'], $url_tourney, ip_stripslashes($board_config['sitename']));
// PM - BEGIN
$founder_id = (defined('FOUNDER_ID') ? FOUNDER_ID : get_founder_id());
include_once(IP_ROOT_PATH . 'includes/class_pm.' . PHP_EXT);
$privmsg_sender = $founder_id;
$privmsg_recipient = $player_id;
$privmsg_subject = $pm_subject;
$privmsg_message = $pm_text;
$privmsg = new class_pm();
$privmsg->send($privmsg_sender, $privmsg_recipient, $privmsg_subject, $privmsg_message);
unset($privmsg);
// PM - END
}
}
// set season-status to running
$sql8 = "UPDATE " . TOURNEY_SEASONS_TABLE . "
SET status = 'running'
WHERE id = '" . $_REQUEST['season_id'] . "'";
if( !($result8 = $db->sql_query($sql8)) )
{
message_die(GENERAL_ERROR, 'Could not update tourney season users information.', '', __LINE__, __FILE__, $sql8);
}
$message = $lang['T_TOURNEY_STARTED'];
}
$message .= '<br /><br />' . sprintf($lang['T_CLICK_RETURN_STATUS_VIEW'], '<a href="' . append_sid('tourney.' . PHP_EXT . '?season_id=' . $_REQUEST['season_id']) . '&mod=tourney_status&act=view&opt=">', '</a>');
message_die(GENERAL_MESSAGE, $message);
}
else
{
$message = $lang['T_WARNING_NO_ACCESS'] . '<br /><br />' . sprintf($lang['T_CLICK_RETURN_TOURNEY'], '<a href="' . append_sid('tourney.' . PHP_EXT . '?season_id=' . $_REQUEST['season_id']) . '">', '</a>');
message_die(GENERAL_MESSAGE, $message);
}
?>
// access for headadmins only
if ($user['usertype_headadmin'])
{
if ($season['status'] == 'running')
{
$message = $lang['T_TOURNEY_RUNNING'];
}
elseif ($season['status'] == 'finished')
{
$message = $lang['T_TOURNEY_FINISHED'];
}
elseif ($season['status'] != 'bracket')
{
$message = $lang['T_SET_BRACKET_FIRST'];
}
else
{
// season users-query
$sql = "SELECT * FROM " . TOURNEY_SEASON_USERS_TABLE . "
WHERE `id_season` = " . $_REQUEST['season_id'] . "
AND `usertype_player` = 1";
if ( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not obtain tourney season users information.', '', __LINE__, __FILE__, $sql);
}
$season_users_row = $db->sql_fetchrow($result);
$script_name = preg_replace('/^\/?(.*?)\/?$/', "\1", trim($board_config['script_path']));
$script_name = ($script_name != '') ? $script_name . '/tourney.' . PHP_EXT : 'tourney.' . PHP_EXT;
$server_name = trim($board_config['server_name']);
$server_protocol = ($board_config['cookie_secure']) ? 'https://' : 'http://';
$server_port = ($board_config['server_port'] <> 80) ? ':' . trim($board_config['server_port']) . '/' : '/';
$url_tourney_adress = $server_protocol . $server_name . $server_port . $script_name . '?season_id=' . $_REQUEST['season_id'];
// send a mail to all player that signed up
// if player is not rejected
if ($season_users_row['rejected'] == 0)
{
// This Query is needed to get the player names to PM ...
$sql2 = "SELECT u1.username AS username_1, u1.user_id AS user_id_1, u1.user_active AS user_active_1, u2.username AS username_2, u2.user_id AS user_id_2, u2.user_active AS user_active_2, m.*
FROM " . USERS_TABLE . " u1, " . USERS_TABLE . " u2, " . TOURNEY_MATCHES_TABLE . " m
WHERE m.id_player1 = u1.user_id
AND m.id_player2 = u2.user_id
AND m.id_season = " . $_REQUEST['season_id'] . "";
if (!($result2 = $db->sql_query($sql2)))
{
message_die(GENERAL_ERROR, 'Could not query private message post information', '', __LINE__, __FILE__, $sql2);
}
$user_n_row = $db->sql_fetchrowset($result2);
for ($x = 0; $x < count($user_n_row); $x++)
{
if ($user_n_row[$x]['user_active_1'])
{
$player_id = $user_n_row[$x]['user_id_1'];
$player_username = $user_n_row[$x]['username_1'];
$opponent_id = $user_n_row[$x]['user_id_2'];
$opponent_username = $user_n_row[$x]['username_2'];
$bracket = $user_n_row[$x]['bracket'];
$round = $user_n_row[$x]['round'];
$match = $user_n_row[$x]['match'];
$round_pre = $round - 1;
$round_post = $round;
$sql3 = "SELECT * FROM " . TOURNEY_DEADLINES_TABLE . "
WHERE `id_season` = '" . $_REQUEST['season_id'] . "'
AND `round` = '" . $bracket . $round_pre . "'";
if ( !$result3 = $db->sql_query($sql3) )
{
message_die(GENERAL_ERROR, 'Could not obtain tourney deadlines information.', '', __LINE__, __FILE__, $sql3);
}
$deadlines_ref1 = $db->sql_numrows($result3);
if ( $deadlines_row1 = $db->sql_fetchrow($result3) )
{
$deadline_pre = create_date($board_config['default_dateformat'], $deadlines_row1['deadline'], $board_config['board_timezone']);
}
$sql4 = "SELECT * FROM " . TOURNEY_DEADLINES_TABLE . "
WHERE `id_season` = '" . $_REQUEST['season_id'] . "'
AND `round` = '" . $bracket . $round_post . "'";
if ( !$result4 = $db->sql_query($sql4) )
{
message_die(GENERAL_ERROR, 'Could not obtain tourney deadlines information.', '', __LINE__, __FILE__, $sql4);
}
$deadlines_ref2 = $db->sql_numrows($result4);
if ( $deadlines_row2 = $db->sql_fetchrow($result4) )
{
$deadline_post = create_date($board_config['default_dateformat'], $deadlines_row2['deadline'], $board_config['board_timezone']);
}
$url_tourney = '[url=' . $url_tourney_adress . ']' . $url_tourney_adress . '[/url]';
$pm_subject = $lang['T_MATCH_NOTIFY'] . ' - ' . $section['name'] . ' - ' . $season['name'];
$pm_text = sprintf($lang['T_MATCH_NOTIFY_TEXT'], $player_username, $bracket, $round, $match, $section['name'], $season['name'], $opponent_username, $deadline_pre, $deadline_post, $url_tourney, ip_stripslashes($board_config['sitename']));
// PM - BEGIN
$founder_id = (defined('FOUNDER_ID') ? FOUNDER_ID : get_founder_id());
include_once(IP_ROOT_PATH . 'includes/class_pm.' . PHP_EXT);
$privmsg_sender = $founder_id;
$privmsg_recipient = $player_id;
$privmsg_subject = $pm_subject;
$privmsg_message = $pm_text;
$privmsg = new class_pm();
$privmsg->send($privmsg_sender, $privmsg_recipient, $privmsg_subject, $privmsg_message);
unset($privmsg);
// PM - END
}
if ($user_n_row[$x]['user_active_2'])
{
$player_id = $user_n_row[$x]['user_id_2'];
$player_username = $user_n_row[$x]['username_2'];
$opponent_id = $user_n_row[$x]['user_id_1'];
$opponent_username = $user_n_row[$x]['username_1'];
$bracket = $user_n_row[$x]['bracket'];
$round = $user_n_row[$x]['round'];
$match = $user_n_row[$x]['match'];
$round_pre = $round - 1;
$round_post = $round;
$sql5 = "SELECT * FROM " . TOURNEY_DEADLINES_TABLE . "
WHERE `id_season` = '" . $_REQUEST['season_id'] . "'
AND `round` = '" . $bracket . $round_pre . "'";
if ( !$result5 = $db->sql_query($sql5) )
{
message_die(GENERAL_ERROR, 'Could not obtain tourney deadlines information.', '', __LINE__, __FILE__, $sql5);
}
$deadlines_ref1 = $db->sql_numrows($result5);
if ( $deadlines_row1 = $db->sql_fetchrow($result5) )
{
$deadline_pre = create_date($board_config['default_dateformat'], $deadlines_row1['deadline'], $board_config['board_timezone']);
}
$sql6 = "SELECT * FROM " . TOURNEY_DEADLINES_TABLE . "
WHERE `id_season` = '" . $_REQUEST['season_id'] . "'
AND `round` = '" . $bracket . $round_post . "'";
if ( !$result6 = $db->sql_query($sql6) )
{
message_die(GENERAL_ERROR, 'Could not obtain tourney deadlines information.', '', __LINE__, __FILE__, $sql6);
}
$deadlines_ref2 = $db->sql_numrows($result6);
if ( $deadlines_row2 = $db->sql_fetchrow($result6) )
{
$deadline_post = create_date($board_config['default_dateformat'], $deadlines_row2['deadline'], $board_config['board_timezone']);
}
$url_tourney = '[url=' . $url_tourney_adress . ']' . $url_tourney_adress . '[/url]';
$pm_subject = $lang['T_MATCH_NOTIFY'] . ' - ' . $section['name'] . ' - ' . $season['name'];
$pm_text = sprintf($lang['T_MATCH_NOTIFY_TEXT'], $player_username, $bracket, $round, $match, $section['name'], $season['name'], $opponent_username, $deadline_pre, $deadline_post, $url_tourney, ip_stripslashes($board_config['sitename']));
// PM - BEGIN
$founder_id = (defined('FOUNDER_ID') ? FOUNDER_ID : get_founder_id());
include_once(IP_ROOT_PATH . 'includes/class_pm.' . PHP_EXT);
$privmsg_sender = $founder_id;
$privmsg_recipient = $player_id;
$privmsg_subject = $pm_subject;
$privmsg_message = $pm_text;
$privmsg = new class_pm();
$privmsg->send($privmsg_sender, $privmsg_recipient, $privmsg_subject, $privmsg_message);
unset($privmsg);
// PM - END
}
}
}
// send a mail to the players that cant participate
// if player is rejected
else
{
// This Query is needed to get the player names to PM ...
$sql7 = "SELECT * FROM " . USERS_TABLE . "
WHERE user_id = '" . $season_users_row['id_user'] . "'";
if (!($result7 = $db->sql_query($sql7)))
{
message_die(GENERAL_ERROR, 'Could not obtain users information', '', __LINE__, __FILE__, $sql7);
}
$user_row = $db->sql_fetchrowset($result7);
for ($y = 0; $y < count($user_row); $y++)
{
$player_id = $user_row[$y]['user_id'];
$player_username = $user_row[$y]['username'];
$url_tourney = '[url=' . $url_tourney_adress . ']' . $url_tourney_adress . '[/url]';
$pm_subject = sprintf($lang['T_MATCH_NOTIFY_OUT'], $section['name'], $season['name']);
$pm_text = sprintf($lang['T_MATCH_NOTIFY_TEXT_OUT'], $player_username, $section['name'], $season['name'], $url_tourney, ip_stripslashes($board_config['sitename']));
// PM - BEGIN
$founder_id = (defined('FOUNDER_ID') ? FOUNDER_ID : get_founder_id());
include_once(IP_ROOT_PATH . 'includes/class_pm.' . PHP_EXT);
$privmsg_sender = $founder_id;
$privmsg_recipient = $player_id;
$privmsg_subject = $pm_subject;
$privmsg_message = $pm_text;
$privmsg = new class_pm();
$privmsg->send($privmsg_sender, $privmsg_recipient, $privmsg_subject, $privmsg_message);
unset($privmsg);
// PM - END
}
}
// set season-status to running
$sql8 = "UPDATE " . TOURNEY_SEASONS_TABLE . "
SET status = 'running'
WHERE id = '" . $_REQUEST['season_id'] . "'";
if( !($result8 = $db->sql_query($sql8)) )
{
message_die(GENERAL_ERROR, 'Could not update tourney season users information.', '', __LINE__, __FILE__, $sql8);
}
$message = $lang['T_TOURNEY_STARTED'];
}
$message .= '<br /><br />' . sprintf($lang['T_CLICK_RETURN_STATUS_VIEW'], '<a href="' . append_sid('tourney.' . PHP_EXT . '?season_id=' . $_REQUEST['season_id']) . '&mod=tourney_status&act=view&opt=">', '</a>');
message_die(GENERAL_MESSAGE, $message);
}
else
{
$message = $lang['T_WARNING_NO_ACCESS'] . '<br /><br />' . sprintf($lang['T_CLICK_RETURN_TOURNEY'], '<a href="' . append_sid('tourney.' . PHP_EXT . '?season_id=' . $_REQUEST['season_id']) . '">', '</a>');
message_die(GENERAL_MESSAGE, $message);
}
?>
thanks in advance