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/new_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.
130 lines (129 sloc)
4.6 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 create a new personnal message | |
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>New PM</title> | |
</head> | |
<body> | |
<div align="center"> | |
<div class="header" style="width: 100%;margin: auto;margin-top: 10px;"> | |
<img width="80%" src="<?php echo $design; ?>/images/logo.png" alt="Forum" /> | |
</div> | |
</div> | |
</body> | |
<?php | |
if(isset($_SESSION['username'])) | |
{ | |
$form = true; | |
$otitle = ''; | |
$orecip = ''; | |
$omessage = ''; | |
if(isset($_POST['title'], $_POST['recip'], $_POST['message'])) | |
{ | |
$otitle = $_POST['title']; | |
$orecip = $_POST['recip']; | |
$omessage = $_POST['message']; | |
if(get_magic_quotes_gpc()) | |
{ | |
$otitle = stripslashes($otitle); | |
$orecip = stripslashes($orecip); | |
$omessage = stripslashes($omessage); | |
} | |
if($_POST['title']!='' and $_POST['recip']!='' and $_POST['message']!='') | |
{ | |
$title = mysqli_real_escape_string($var,$otitle); | |
$recip = mysqli_real_escape_string($var,$orecip); | |
$message = mysqli_real_escape_string($var,nl2br(htmlentities($omessage, ENT_QUOTES, 'UTF-8'))); | |
$dn1 = mysqli_fetch_array(mysqli_query($var,'select count(id) as recip, id as recipid, (select count(*) from pm) as npm from users where username="'.$recip.'"')); | |
if($dn1['recip']==1) | |
{ | |
if($dn1['recipid']!=$_SESSION['userid']) | |
{ | |
$id = $dn1['npm']+1; | |
if(mysqli_query($var,'insert into pm (id, id2, title, user1, user2, message, timestamp, user1read, user2read)values("'.$id.'", "1", "'.$title.'", "'.$_SESSION['userid'].'", "'.$dn1['recipid'].'", "'.$message.'", "'.time().'", "yes", "no")')) | |
{ | |
?> | |
<div class="message">The PM have successfully been sent.<br /> | |
<a href="list_pm.php">List of your Personal Messages</a></div> | |
<?php | |
$form = false; | |
} | |
else | |
{ | |
$error = 'An error occurred while sending the PM.'; | |
} | |
} | |
else | |
{ | |
$error = 'You cannot send a PM to yourself.'; | |
} | |
} | |
else | |
{ | |
$error = 'The recipient of your PM doesn\'t exist.'; | |
} | |
} | |
else | |
{ | |
$error = 'A field is not filled.'; | |
} | |
} | |
elseif(isset($_GET['recip'])) | |
{ | |
$orecip = $_GET['recip']; | |
} | |
if($form) | |
{ | |
if(isset($error)) | |
{ | |
echo '<div class="message">'.$error.'</div>'; | |
} | |
?> | |
<!-- <div class="contentnewpm"> --> | |
<div class="contentusers"> | |
<?php | |
$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> > <a href="list_pm.php">List of you PMs</a> > New PM | |
</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> | |
<h1>New Personal Message</h1> | |
<form action="new_pm.php" method="post"> | |
Please fill this form to send a PM:<br /> | |
<label for="title">Title</label><input type="text" value="<?php echo htmlentities($otitle, ENT_QUOTES, 'UTF-8'); ?>" id="title" name="title" /><br /> | |
<label for="recip">Recipient<span class="small">(Username)</span></label><input type="text" value="<?php echo htmlentities($orecip, ENT_QUOTES, 'UTF-8'); ?>" id="recip" name="recip" /><br /> | |
<label for="message">Message</label><textarea cols="35" rows="5" id="message" name="message"><?php echo htmlentities($omessage, ENT_QUOTES, 'UTF-8'); ?></textarea><br /> | |
<input type="submit" value="Send" /> | |
</form> | |
</div> | |
<?php | |
} | |
} | |
else | |
{ | |
?> | |
<div class="box_login"> | |
<?php header("location:login.php?msg=Login First to use service"); //zubair?> | |
</div> | |
<?php | |
} | |
?> | |
<!-- <div class="foot"> | |
<p><b>Water Control System and Discussion Portal for Farmers</b></p> | |
</div> --> | |
</body> | |
</html> |