forked from kleopatra999/Spickly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmp.php
158 lines (155 loc) · 7.11 KB
/
mp.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<?php if (!isset($opt)) die("<script>location.href='in.php?p=profile';</script>");
if (isset($_GET["t"]) && $_GET["t"]) {
$idYo = $user_row["member_id"];
?>
<script>
function mpLink(id){
window.location="in.php?p=mp&mp="+id;
}
</script>
<div id="page">
<div id="sidebar_mp">
<a href="in.php?p=mp&t=1">Bandeja de entrada</a>
<?php
if ($nuevosmp > 0)echo '<img id="entrada" src="resources/images/inbox-new.png" alt="nuevo" title="¡Nuevos Mensajes!"/>';
else echo '<img id="entrada" src="resources/images/inbox-entrada.png" alt="entrada" title="Entrada"/>';
?>
<a id="second-a" href="in.php?p=mp&t=2">Bandeja de salida</a>
<img id="salida" src="resources/images/inbox-salida.png" alt="salida" title="Salida"/>
</div>
<div id="mp_container">
<a href="in.php?p=mp"><input type="button" class="boton" value="Nuevo mensaje" style="float:right; bottom: 40px;"></a>
<?php if($_GET["t"] == 1) {
$resIn = new Pagination("SELECT * FROM mps WHERE member_id_receive='$idYo' ORDER BY date DESC");
$resIn->pgSelectItemperPage(5);
$resIn->pgSelectType("mpin");
$resin = $resIn->pgDoPagination();
?>
<h1>Mensajes recibidos</h1>
<hr>
<div id="pgmpin">
<table border="0" width="100%" id="bordertable" cellspacing="0">
<tr>
<th style="position: relative; text-align: left;"><span>Asunto</span></th>
<th style="position: relative; text-align: left;"><span>De</span></th>
<th style="position: relative; text-align: left;"><span>Estado</span></th>
<th style="position: relative; text-align: left;"><span>Fecha</span></th>
<th style="position: relative; text-align: left;"><span>Borrar</span></th>
</tr>
<?php
while ($row = mysql_fetch_array($resin)) {
$raw = fetchUser($row["member_id_send"]);
if ($row["readed"] == 1) $readed = '<span style="color:#00AB00;">Leido</span>';
else $readed = '<span style="color:red;">No leido</span>';
echo '<tr id="mp_'.$row["id"].'">
<td onclick="mpLink('.$row['id'].')"><span>'.$row['topic'].'</span></td>
<td onclick="mpLink('.$row['id'].')"><span>'.$raw["firstname"]." ".$raw["lastname"].'</span></td>
<td onclick="mpLink('.$row['id'].')"><span>'.$readed.'</span></td>
<td onclick="mpLink('.$row['id'].')"><span>'.$row["date"].'</span></td>
<td><a href="#" style="color:red;" onclick="deleteMp('.$row['id'].')">Eliminar</a></td>
</tr></span>';
}
echo $resIn->pgShowAjaxPagination(); ?>
</table>
</div>
<?php } else if ($_GET["t"] == 2) {
$resOut = new Pagination("SELECT * FROM mps WHERE member_id_send='$idYo' ORDER BY date DESC");
$resOut->pgSelectItemperPage(5);
$resOut->pgSelectType("mpout");
$resout = $resOut->pgDoPagination();
?>
<h1>Mensajes enviados</h1>
<hr>
<div id="pgmpout">
<table border="0" width="100%" id="bordertable" cellspacing="0">
<tr>
<th style="position: relative; text-align: left;"><span>Asunto</span></th>
<th style="position: relative; text-align: left;"><span>Para</span></th>
<th style="position: relative; text-align: left;"><span>Fecha</span></th>
<th style="position: relative; text-align: left;"><span>Borrar</span></th>
</tr>
<?php
while ($row = mysql_fetch_array($resout)) {
$raw = fetchUser($row["member_id_receive"]);
echo '<tr id="mp_'.$row["id"].'">
<td onclick="mpLink('.$row['id'].')"><span>'.$row['topic'].'</span></td>
<td onclick="mpLink('.$row['id'].')"><span>'.$raw["firstname"]." ".$raw["lastname"].'</span></td>
<td onclick="mpLink('.$row['id'].')"><span>'.$row["date"].'</span></td>
<td><a href="#" style="color:red;" onclick="deleteMp('.$row['id'].')">Eliminar</a></td>
</tr>';
}
echo $resOut->pgShowAjaxPagination();?>
</table>
</div>
<?php } ?>
</div>
</div>
<?php
} else if ((!isset($_GET["t"]) || !$_GET["t"]) && (isset($_GET["mp"]) && $_GET["mp"])) {
$idmp=mysql_real_escape_string($_GET["mp"]);
$row = fetchQuery("SELECT * FROM mps WHERE id=$idmp");
if ($row["member_id_send"] == $user_row["member_id"]) {
$u_row = fetchUser($row["member_id_receive"]);
$type=0;
} else {
$u_row = fetchUser($row["member_id_send"]);
$type=1;
}
if ($row["read"] == 0 && $user_row["member_id"] == $row["member_id_receive"]) mysql_query("UPDATE mps SET readed=1 WHERE id=$idmp") or die(mysql_error());
?>
<div id="page">
<div id="sidebar_mp">
<a href="in.php?p=mp&t=1">Bandeja de entrada</a>
<?php
if ($nuevosmp > 0) echo '<img id="entrada" src="resources/images/inbox-new.png" alt="nuevo" title="¡Nuevos Mensajes!"/>';
else echo '<img id="entrada" src="resources/images/inbox-entrada.png" alt="entrada" title="Entrada"/>';
?>
<a id="second-a" href="in.php?p=mp&t=2">Bandeja de salida</a>
<img id="salida" src="resources/images/inbox-salida.png" alt="salida" title="Salida"/>
</div>
<div id="inboxin">
<?php
//Cojo las imagenes de perfil Por ID
$images = getProfilePhotoByPhotoId($u_row["prf_img"]);
?>
<table border="0" style="width:100%;" align="center" id="mensaje_recibido" cellspacing="0">
<tr>
<td style="margin:0 auto; width:100%;"><?php if ($type == 1) echo "De "; else echo "Para "; ?>
<?php echo "<img style='border-radius:7px;' src=".$images." width='30' height='30'>";?> <?php echo"<a href='in.php?p=profile&id=".$u_row["member_id"]."'>".$u_row["firstname"]." ".$u_row["lastname"]."</a>"; ?><hr></td>
</tr>
<tr>
<td style="margin:0 auto; width:100%;"><h2>Asunto:</h2>
<?php echo"<div id='asunto'>".$row['topic']."</div>"; ?><hr></td>
</tr>
<tr>
<td style="display:none;"> </td>
<td style="margin:0 auto; width:100%; "><h2>Mensaje:</h2>
<?php echo $row['message']; ?><hr></td>
</tr>
</table>
<br>
<a id="button" style="height:20px;" class="boton" href="in.php?p=mp&id=<?php echo $u_row["member_id"]; ?>"><?php if ($type) echo "Responder"; else echo "Reenviar"; ?></a>
</div>
</div>
<?php
} else if ((!isset($_GET["t"]) || !$_GET["t"]) && (!isset($_GET["mp"]) || !$_GET["mp"])) {
if (isset($_GET["id"])) $u_row = fetchUser($_GET["id"]);
?>
<div id="page">
<div id="inboxin">
<form action="in_actions.php?a=cmp" method="POST">
<h2>Para</h2>
<input type="hidden" name="receiver" id="receiver" value="<?php if (isset($u_row["member_id"])) { ?><?php echo $u_row["member_id"]; ?><?php } ?>" />
<input id="au_receiver" name="receivername" type="text" onkeypress="getSuggestToInput(document.getElementById('au_receiver').value, 'mpfriend', 'au_receiver', 'receiver')" autocomplete="off" <?php if (isset($_GET["id"])) echo 'disabled="disabled"'; ?> value="<?php if (isset($_GET["id"])) echo $u_row["firstname"]." ". $u_row["lastname"]; ?>" /><br />
<ul id="mpfriend"></ul>
<h2>Asunto</h2>
<input align="center" id="topic_mp" name="topic" size="50" maxlength="60" width="100px" type="text" /><br />
<h2>Mensaje</h2>
<textarea name="message" class="inputbox" type="text"></textarea><br />
<input type="submit" class="boton" value="Enviar">
</form>
</div>
</div>
<?php
} else die("<script>location.href='in.php?p=profile';</script>");
?>