Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Watersys/list_pm.php
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
126 lines (123 sloc)
4.95 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//This page let display the list of personnal message of an user | |
include('config.php'); | |
?> | |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous"> | |
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script> | |
<link href="<?php echo $design; ?>/style.css" rel="stylesheet" title="Style" /> | |
<title>Personal Messages</title> | |
</head> | |
<body> | |
<div align="center"> | |
<div class="header" style="margin: auto;width: 100%;margin-top: 10px"> | |
<a href="<?php echo $url_home; ?>"><img width="80%" src="<?php echo $design; ?>/images/logo.png" alt="Forum" /></a> | |
</div></div> | |
<!-- <div class="contentlistpm"> --> | |
<div class="contentusers"> | |
<?php | |
if(isset($_SESSION['username'])) | |
{ | |
$req1 = mysqli_query($var,'select m1.id, m1.title, m1.timestamp, count(m2.id) as reps, users.id as userid, users.username from pm as m1, pm as m2,users where ((m1.user1="'.$_SESSION['userid'].'" and m1.user1read="no" and users.id=m1.user2) or (m1.user2="'.$_SESSION['userid'].'" and m1.user2read="no" and users.id=m1.user1)) and m1.id2="1" and m2.id=m1.id group by m1.id order by m1.id desc'); | |
$req2 = mysqli_query($var,'select m1.id, m1.title, m1.timestamp, count(m2.id) as reps, users.id as userid, users.username from pm as m1, pm as m2,users where ((m1.user1="'.$_SESSION['userid'].'" and m1.user1read="yes" and users.id=m1.user2) or (m1.user2="'.$_SESSION['userid'].'" and m1.user2read="yes" and users.id=m1.user1)) and m1.id2="1" and m2.id=m1.id group by m1.id order by m1.id desc'); | |
$nb_new_pm = mysqli_fetch_array(mysqli_query($var,'select count(*) as nb_new_pm from pm where ((user1="'.$_SESSION['userid'].'" and user1read="no") or (user2="'.$_SESSION['userid'].'" and user2read="no")) and id2="1"')); | |
$nb_new_pm = $nb_new_pm['nb_new_pm']; | |
?> | |
<div class="box"> | |
<div class="box_left"> | |
<a href="<?php echo $url_home; ?>">WCSF Index</a> > List of your Personal Messages | |
</div> | |
<div class="box_right"> | |
<a href="list_pm.php">Your messages(<?php echo $nb_new_pm; ?>)</a> - <a href="profile.php?id=<?php echo $_SESSION['userid']; ?>"><?php echo htmlentities($_SESSION['username'], ENT_QUOTES, 'UTF-8'); ?></a> (<a href="login.php">Logout</a>) | |
</div> | |
<div class="clean"></div> | |
</div> | |
<?php | |
if(isset($_SESSION['username']) and $_SESSION['username']==$admin) | |
{?> | |
Add/Edit New Announcement<br /> | |
<a href="announcement.php" class="button">Add Announcement</a><br /> | |
<?php }?> | |
This is the list of your personal messages:<br /> | |
<a href="new_pm.php" class="button">New Personal Message</a><br /> | |
<h3>Unread messages(<?php echo intval(mysqli_num_rows($req1)); ?>):</h3> | |
<table class="list_pm"> | |
<tr> | |
<th class="title_cell">Title</th> | |
<th>Nb. Replies</th> | |
<th>Participant</th> | |
<th>Date Sent</th> | |
</tr> | |
<?php | |
while($dn1 = mysqli_fetch_array($req1)) | |
{ | |
?> | |
<tr> | |
<td class="left"><a href="read_pm.php?id=<?php echo $dn1['id']; ?>"><?php echo htmlentities($dn1['title'], ENT_QUOTES, 'UTF-8'); ?></a></td> | |
<td><?php echo $dn1['reps']-1; ?></td> | |
<td><a href="profile.php?id=<?php echo $dn1['userid']; ?>"><?php echo htmlentities($dn1['username'], ENT_QUOTES, 'UTF-8'); ?></a></td> | |
<td><?php echo date('d/m/Y H:i:s' ,$dn1['timestamp']); ?></td> | |
</tr> | |
<?php | |
} | |
if(intval(mysqli_num_rows($req1))==0) | |
{ | |
?> | |
<tr> | |
<td colspan="4" class="center">You have no unread message.</td> | |
</tr> | |
<?php | |
} | |
?> | |
</table> | |
<br /> | |
<h3>Read messages(<?php echo intval(mysqli_num_rows($req2)); ?>):</h3> | |
<table class="list_pm"> | |
<tr> | |
<th class="title_cell">Title</th> | |
<th>Nb. Replies</th> | |
<th>Participant</th> | |
<th>Date Sent</th> | |
</tr> | |
<?php | |
while($dn2 = mysqli_fetch_array($req2)) | |
{ | |
?> | |
<tr> | |
<td class="left"><a href="read_pm.php?id=<?php echo $dn2['id']; ?>"><?php echo htmlentities($dn2['title'], ENT_QUOTES, 'UTF-8'); ?></a></td> | |
<td><?php echo $dn2['reps']-1; ?></td> | |
<td><?php echo htmlentities($dn2['username'], ENT_QUOTES, 'UTF-8');?></td> | |
<td><?php echo date('d/m/Y H:i:s' ,$dn2['timestamp']); ?></td> | |
</tr> | |
<?php | |
} | |
if(intval(mysqli_num_rows($req2))==0) | |
{ | |
?> | |
<tr> | |
<td colspan="4" class="center">You have no read message.</td> | |
</tr> | |
<?php | |
} | |
?> | |
</table> | |
<?php | |
} | |
else | |
{ | |
?> | |
<div class="box_login"> | |
<?php header("location:login.php?msg=Login First to use service"); //zubair?> | |
</div> | |
<?php | |
} | |
?> | |
</div> | |
<!-- <div class="foot"> | |
<p><b>Water Control System and Discussion Portal for Farmers</b></p> | |
</div> --> | |
</body> | |
</html> |