예제 #1
0
function print_messages($target_id, $permissions, $clan_id, $col_arr)
{
    global $db_name, $user, $user_options, $game_info, $last_time, $cw, $st;
    $clan_string_sql = "";
    $clan_forum_str = "";
    $ret_str = "";
    if ($target_id < 0) {
        //forums
        $last_access = $user['last_access_forum'];
        if ($target_id == -5) {
            //clan forum
            $clan_string_sql = " && clan_id = '{$clan_id}' ";
            $clan_forum_str = "&amp;clan_id={$clan_id}";
            $last_access = $user['last_access_clan_forum'];
        }
        if (empty($last_time)) {
            //not set time to go back to
            $forum_time = time() - $user_options['forum_back'] * 3600;
        } else {
            $forum_time = (int) $last_time;
        }
    } else {
        //user messages
        $forum_time = 0;
        db("select count(message_id) from {$db_name}_messages where login_id = '{$target_id}'");
        $counted = dbr();
        $last_access = $user['last_access_msg'];
    }
    //central forum, different table. - external from game
    if ($target_id == -99 || $target_id == -50) {
        db("select *, sender_id as login_id from se_central_messages where timestamp > {$forum_time} && forum_id = '{$target_id}' order by timestamp desc");
        $user_options['show_sigs'] = 0;
        //don't try to show sigs in these forums
    } else {
        //in-game message table.
        //note: due to the fact there is no user -1, this has to cheat and select the sig of user id 1 (admin who is always in game) to ensure messages are loaded. admin sig is not actually show though.
        db("select *, sender_id as login_id from {$db_name}_messages where login_id = '{$target_id}' and timestamp > {$forum_time} {$clan_string_sql} order by timestamp desc");
    }
    $sig_array = array();
    $i = 0;
    while ($messages = dbr(1)) {
        $printed_name = "";
        //undeclare to next entry
        $no_reply = 0;
        //whether can reply
        $cols = 2;
        //num of cols within this post.
        //no sig, or not showing
        if ($user_options['show_sigs'] == 0 || $messages['login_id'] == -1) {
            $messages['sig'] = "";
            //sig already loaded from previous message
        } elseif (isset($sig_array[$messages['login_id']])) {
            $messages['sig'] = $sig_array[$messages['login_id']];
            //load the players sig
        } else {
            db2("select sig from {$db_name}_users where login_id = '{$messages['login_id']}'");
            $temp_sig = dbr2();
            $sig_array[$messages['login_id']] = mcit(stripslashes("\n\n" . $temp_sig['sig']));
            $messages['sig'] = $sig_array[$messages['login_id']];
        }
        $coul_fond = $messages['timestamp'] > $last_access ? $col_arr[3] : $col_arr[0];
        $ret_str .= "\n<table border='0' cellpadding='5'>\n<tr bgcolor='{$coul_fond}'>";
        //time and date of message.
        $ret_str .= "\n<td width='100'>\n<b>" . date("M d - H:i", $messages['timestamp']) . "</b></td>\n<td width='250'>";
        if ($messages['login_id'] >= 1 && $target_id > -50) {
            //message by a player for in-game
            $printed_name = print_name($messages);
        } elseif (!empty($messages['forum_id'])) {
            //a central forum
            $no_reply = 1;
            $printed_name = "\n{$messages['sender_name']}";
        }
        if (empty($printed_name)) {
            //message by an automated entity, or retired player
            $no_reply = 1;
            $printed_name = "\n<b class='b1'>{$messages['sender_name']}</b>";
        }
        if ($target_id == -1) {
            $no_reply = 1;
        }
        $ret_str .= $printed_name;
        $ret_str .= "</td>\n";
        //player link to delete messages (with checkboxes)
        if ($target_id > -50) {
            //can't do these things with the central forums
            $cols = 3;
            $ret_str .= "<td align='right' width='230'>";
            if ($no_reply == 0) {
                //no reply link for certain messages
                $ret_str .= "<a href='message.php?target_id={$messages['sender_id']}&amp;reply_to={$messages['message_id']}'>" . $cw['reply'] . "</a> - ";
            }
            $ret_str .= "<a href='message.php?forward={$messages['message_id']}'>" . $cw['forward'] . "</a> - <a href='diary.php?log_ent={$messages['message_id']}'>" . $cw['log'] . "</a>";
            if ($target_id > 0 && $counted[0] > 1) {
                $ret_str .= " - <a href='{$_SERVER['PHP_SELF']}?killmsg={$messages['message_id']}'>" . $cw['delete'] . "</a> - <input type='checkbox' name='del_mess[{$messages['message_id']}]' value='{$messages['message_id']}' />";
                //admin link to delete messages in forum
            } elseif ($permissions == 1) {
                $ret_str .= " - <a href='{$_SERVER['PHP_SELF']}?target_id={$target_id}&amp;killmsg={$messages['message_id']}{$clan_forum_str}'>" . $cw['delete'] . "</a>";
            }
            $ret_str .= "</td>";
        }
        $ret_str .= "</tr>\n<tr>\n<td colspan='{$cols}' bgcolor='{$col_arr['1']}'><blockquote>{$messages['text']}</blockquote></td></tr>";
        if (!empty($messages['sig'])) {
            $ret_str .= "<tr><td colspan='{$cols}' bgcolor='{$col_arr['2']}'>{$messages['sig']}</td></tr>";
        }
        $ret_str .= "\n</table><p />";
        $i++;
    }
    return $ret_str;
}
예제 #2
0
        //plain normal message.
        $page_str = $people_can_mess;
    }
    //can be previewing and forwarding/replying, so not part of above if structure.
    if (isset($_POST['preview'])) {
        //previewing
        $prev = mcit($text);
        $page_str .= $people_can_mess . "<p />" . $st[907] . ": <p /><hr width=75% align=left><blockquote>{$prev}</blockquote><hr width='75%' align='left'><br />";
        $data_for_textbox = $text;
        //unset so don't end up back at the preview when clicking submit
        unset($_POST['preview'], $_POST['text']);
    }
    get_var('Send Message', 'message.php', $page_str, 'msg', $data_for_textbox);
} else {
    //done with the text
    $text = mcit($text);
}
//send messages
// if there are more than 100 characters in a line with no spaces, then complain.
if (preg_match("/\\S{100,}/", $text)) {
    print_page($cw['error'], $st[908] . " ;-)");
}
//send a message to each of the clan mates.
if ($target_id == -2) {
    db2("select login_id from {$db_name}_users where clan_id='{$clan_id}' && clan_id > 0");
    $target_member = dbr2(1);
    while ($target_member) {
        send_message($target_member['login_id'], $text);
        send_templated_email($target_member['login_id'], 'message');
        $target_member = dbr2(1);
    }
예제 #3
0
} else {
    if ($num_ent[0] < $max) {
        $text .= "<p /><br /><a href='{$filename}?add=1'>" . $cw['add_entry'] . "</a>";
    } else {
        $text .= $st[161];
    }
    $text .= $st[162];
    $text .= make_table(array($cw['date_entered'], $cw['entry']));
    if ($num_ent[0] > 1) {
        $text .= "<FORM method=POST action=diary.php name=quick_del><input type=hidden name=del_select value=1 />";
    }
    db2("select * from {$db_name}_diary where login_id = '{$user['login_id']}' order by timestamp desc");
    while ($entry = dbr2(1)) {
        //list entries
        $entry['entry'] = stripslashes($entry['entry']);
        $entry['entry'] = mcit($entry['entry']);
        $e_num = $entry['entry_id'];
        $entry['entry_id'] = "- <a href='{$filename}?edit={$e_num}'>" . $cw['edit'] . "</a> - <a href='{$filename}?delete={$e_num}'>" . $cw['delete'] . "</a>";
        if ($num_ent[0] > 1) {
            $entry['entry_id'] .= "- <input type=checkbox name=del_ent[{$e_num}] value={$e_num} />";
        }
        $text .= make_row(array("<b>" . date("M d - H:i", $entry['timestamp']) . "</b>", $entry['entry'], $entry['entry_id']));
    }
    $text .= "</table><br />";
}
if ($num_ent[0] > 1) {
    //show the big delete options
    $text .= "<br /><input type='submit' value='" . $cw['delete_selected_entries'] . "' />  - <a href=javascript:TickAll(\"quick_del\")>" . $cw['invert_entry_selection'] . "</a></form><br />";
    $text .= "<br /><a href='{$filename}?delete_all=1'>" . $st[163];
}
$rs = "<p /><a href='location.php'>" . $cw['back_star_system'] . "</a>";