Subversion Repositories svnkaklik

Rev

Details | Last modification | View Log

Rev Author Line No. Line
36 kaklik 1
<?php
2
 
3
/*************************************************************
4
*  TorrentFlux - PHP Torrent Manager
5
*  www.torrentflux.com
6
**************************************************************/
7
/*
8
    This file is part of TorrentFlux.
9
 
10
    TorrentFlux is free software; you can redistribute it and/or modify
11
    it under the terms of the GNU General Public License as published by
12
    the Free Software Foundation; either version 2 of the License, or
13
    (at your option) any later version.
14
 
15
    TorrentFlux is distributed in the hope that it will be useful,
16
    but WITHOUT ANY WARRANTY; without even the implied warranty of
17
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
    GNU General Public License for more details.
19
 
20
    You should have received a copy of the GNU General Public License
21
    along with TorrentFlux; if not, write to the Free Software
22
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23
*/
24
 
25
include_once("config.php");
26
include_once("functions.php");
27
 
28
 
29
if(empty($cfg['user']))
30
{
31
     // the user probably hit this page direct
32
    header("location: index.php");
33
    exit;
34
}
35
 
36
$delete = getRequestVar('delete');
37
if(!empty($delete))
38
{
39
    DeleteMessage($delete);
40
    header("location: ".$_SERVER['PHP_SELF']);
41
}
42
 
43
$mid = getRequestVar('mid');
44
if (!empty($mid))
45
{
46
    list($from_user, $message, $ip, $time, $isnew, $force_read) = GetMessage($mid);
47
    if(!empty($from_user) && $isnew == 1)
48
    {
49
        // We have a Message that is being seen
50
        // Mark it as NOT new.
51
        MarkMessageRead($mid);
52
    }
53
 
54
    DisplayHead(_MESSAGES);
55
    $message = check_html($message, "nohtml");
56
    $message = str_replace("\n", "<br>", $message);
57
    echo "<a href=\"".$_SERVER['PHP_SELF']."\"><img src=\"images/up_dir.gif\" width=16 height=16 title=\""._RETURNTOMESSAGES."\" border=0>"._RETURNTOMESSAGES."</a><br>";
58
    echo "<table width=\"740\" border=1 bordercolor=\"".$cfg["table_admin_border"]."\" cellpadding=\"2\" cellspacing=\"0\"><tr>";
59
    echo "<td bgcolor=\"".$cfg["table_header_bg"]."\" colspan=2>";
60
    echo "<table width=\"100%\" cellpadding=0 cellspacing=0 border=0><tr><td>";
61
    echo _FROM.": <strong>".$from_user."</strong></td><td align=\"right\">";
62
    if (IsUser($from_user))
63
    {
64
        echo "<a href=\"message.php?to_user=".$from_user."&rmid=".$mid."\"><img src=\"images/reply.gif\" width=16 height=16 title=\""._REPLY."\" border=0></a>";
65
    }
66
    echo "<a href=\"".$_SERVER['PHP_SELF']."?delete=".$mid."\"><img src=\"images/delete_on.gif\" width=16 height=16 title=\""._DELETE."\" border=0></a></td></tr></table>";
67
    echo "</td></tr>";
68
    echo "<tr><td colspan=2>"._DATE.":  <strong>".date(_DATETIMEFORMAT, $time)."</strong></td></tr>";
69
    echo "</tr><td colspan=2 bgcolor=\"".$cfg["table_data_bg"]."\">"._MESSAGE.":<blockquote><strong>".$message."</strong></blockquote></td></tr>";
70
    echo "</table>";
71
}
72
else
73
{
74
    DisplayHead(_MESSAGES);
75
    // read and display all messages in a list.
76
    $inx = 0;
77
    DisplayMessageList();
78
    echo "<table width=\"760\" border=1 bordercolor=\"".$cfg["table_admin_border"]."\" cellpadding=\"2\" cellspacing=\"0\" bgcolor=\"".$cfg["table_data_bg"]."\"><tr>";
79
    echo "<td bgcolor=\"".$cfg["table_header_bg"]."\" width=\"20%\"><div align=center class=\"title\">"._FROM."</div></td>";
80
    echo "<td bgcolor=\"".$cfg["table_header_bg"]."\"><div align=center class=\"title\">"._MESSAGE."</div></td>";
81
    echo "<td bgcolor=\"".$cfg["table_header_bg"]."\" width=\"20%\"><div align=center class=\"title\">"._DATE."</div></td>";
82
    echo "<td bgcolor=\"".$cfg["table_header_bg"]."\" width=\"10%\"><div align=center class=\"title\">"._ADMIN."</div></td>";
83
    echo "</tr>";
84
 
85
    $sql = "SELECT mid, from_user, message, IsNew, ip, time, force_read FROM tf_messages WHERE to_user=".$db->qstr($cfg['user'])." ORDER BY time";
86
    $result = $db->Execute($sql);
87
    showError($db,$sql);
88
 
89
    while(list($mid, $from_user, $message, $new, $ip, $time, $force_read) = $result->FetchRow())
90
    {
91
        if($new == 1)
92
        {
93
            $mail_image = "images/new_message.gif";
94
        }
95
        else
96
        {
97
            $mail_image = "images/old_message.gif";
98
        }
99
        $display_message = check_html($message, "nohtml");
100
        if(strlen($display_message) >= 40) { // needs to be trimmed
101
            $display_message = substr($display_message, 0, 39);
102
            $display_message .= "...";
103
        }
104
        $link = $_SERVER['PHP_SELF']."?mid=".$mid;
105
 
106
        echo "<tr><td>&nbsp;&nbsp;<a href=\"".$link."\"><img src=\"".$mail_image."\" width=14 height=11 title=\"\" border=0 align=\"absmiddle\"></a>&nbsp;&nbsp; <a href=\"".$link."\">".$from_user."</a></td>";
107
        echo "<td><a href=\"".$link."\">".$display_message."</a></td>";
108
        echo "<td align=\"center\"><a href=\"".$link."\">".date(_DATETIMEFORMAT, $time)."</a></td>";
109
        echo "<td align=\"right\">";
110
 
111
        // Is this a force_read from an admin?
112
        if ($force_read == 1)
113
        {
114
            // Yes, then don't let them delete the message yet
115
            echo "<img src=\"images/delete_off.gif\" width=16 height=16 title=\"\" border=0>";
116
        }
117
        else
118
        {
119
            // No, let them reply or delete it
120
            if (IsUser($from_user))
121
            {
122
                echo "<a href=\"message.php?to_user=".$from_user."&rmid=".$mid."\"><img src=\"images/reply.gif\" width=16 height=16 title=\""._REPLY."\" border=0></a>";
123
            }
124
            echo "<a href=\"".$_SERVER['PHP_SELF']."?delete=".$mid."\"><img src=\"images/delete_on.gif\" width=16 height=16 title=\""._DELETE."\" border=0></a></td></tr>";
125
        }
126
        $inx++;
127
    } // End While
128
    echo "</table>";
129
 
130
    if($inx == 0)
131
    {
132
        echo "<div align=\"center\"><strong>-- "._NORECORDSFOUND." --</strong></div>";
133
    }
134
 
135
} // end the else
136
 
137
DisplayFoot();
138
?>