Advertisement
chappati21

Popraw ten kod to bedziesz mistrzem ;)

Mar 13th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.67 KB | None | 0 0
  1. <?php
  2. //This page display a personnal message
  3. include('config.php');
  4. ?>
  5. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  6. <html xmlns="http://www.w3.org/1999/xhtml">
  7. <head>
  8. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  9. <link href="<?php echo $design; ?>/style.css" rel="stylesheet" title="Style" />
  10. <title>Read a PM</title>
  11. </head>
  12. <body>
  13. <div class="header">
  14. <a href="<?php echo $url_home; ?>"><img src="<?php echo $design; ?>/images/logo.png" alt="Forum" /></a>
  15. </div>
  16. <?php
  17. if(isset($_SESSION['username']))
  18. {
  19. if(isset($_GET['id']))
  20. {
  21. $id = intval($_GET['id']);
  22. $req1 = mysql_query('select title, user1, user2 from pm where id="'.$id.'" and id2="1"');
  23. $dn1 = mysql_fetch_array($req1);
  24. if(mysql_num_rows($req1)==1)
  25. {
  26. if($dn1['user1']==$_SESSION['userid'] or $dn1['user2']==$_SESSION['userid'])
  27. {
  28. if($dn1['user1']==$_SESSION['userid'])
  29. {
  30. mysql_query('update pm set user1read="yes" where id="'.$id.'" and id2="1"');
  31. $user_partic = 2;
  32. }
  33. else
  34. {
  35. mysql_query('update pm set user2read="yes" where id="'.$id.'" and id2="1"');
  36. $user_partic = 1;
  37. }
  38. $req2 = mysql_query('select pm.timestamp, pm.message, users.id as userid, users.username, users.avatar from pm, users where pm.id="'.$id.'" and users.id=pm.user1 order by pm.id2');
  39. if(isset($_POST['message']) and $_POST['message']!='')
  40. {
  41. $message = $_POST['message'];
  42. if(get_magic_quotes_gpc())
  43. {
  44. $message = stripslashes($message);
  45. }
  46. $message = mysql_real_escape_string(nl2br(htmlentities($message, ENT_QUOTES, 'UTF-8')));
  47. if(mysql_query('insert into pm (id, id2, title, user1, user2, message, timestamp, user1read, user2read)values("'.$id.'", "'.(intval(mysql_num_rows($req2))+1).'", "", "'.$_SESSION['userid'].'", "", "'.$message.'", "'.time().'", "", "")') and mysql_query('update pm set user'.$user_partic.'read="yes" where id="'.$id.'" and id2="1"'))
  48. {
  49. ?>
  50. <div class="message">Your reply has successfully been sent.<br />
  51. <a href="read_pm.php?id=<?php echo $id; ?>">Go to the PM</a></div>
  52. <?php
  53. }
  54. else
  55. {
  56. ?>
  57. <div class="message">An error occurred while sending the reply.<br />
  58. <a href="read_pm.php?id=<?php echo $id; ?>">Go to the PM</a></div>
  59. <?php
  60. }
  61. }
  62. else
  63. {
  64. ?>
  65. <div class="content">
  66. <?php
  67. if(isset($_SESSION['username']))
  68. {
  69. $nb_new_pm = mysql_fetch_array(mysql_query('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"'));
  70. $nb_new_pm = $nb_new_pm['nb_new_pm'];
  71. ?>
  72. <div class="box">
  73. <div class="box_left">
  74. <a href="<?php echo $url_home; ?>">Forum Index</a> &gt; <a href="list_pm.php">List of your PMs</a> &gt; Read a PM
  75. </div>
  76. <div class="box_right">
  77. <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>)
  78. </div>
  79. <div class="clean"></div>
  80. </div>
  81. <?php
  82. }
  83. else
  84. {
  85. ?>
  86. <div class="box">
  87. <div class="box_left">
  88. <a href="<?php echo $url_home; ?>">Forum Index</a> &gt; <a href="list_pm.php">List of your PMs</a> &gt; Read a PM
  89. </div>
  90. <div class="box_right">
  91. <a href="signup.php">Sign Up</a> - <a href="login.php">Login</a>
  92. </div>
  93. <div class="clean"></div>
  94. </div>
  95. <?php
  96. }
  97. ?>
  98. <h1><?php echo $dn1['title']; ?></h1>
  99. <table class="messages_table">
  100. <tr>
  101. <th class="author">User</th>
  102. <th>Message</th>
  103. </tr>
  104. <?php
  105. while($dn2 = mysql_fetch_array($req2))
  106. {
  107. ?>
  108. <tr>
  109. <td class="author center"><?php
  110. if($dn2['avatar']!='')
  111. {
  112. echo '<img src="'.htmlentities($dn2['avatar']).'" alt="Image Perso" style="max-width:100px;max-height:100px;" />';
  113. }
  114. ?><br /><a href="profile.php?id=<?php echo $dn2['userid']; ?>"><?php echo $dn2['username']; ?></a></td>
  115. <td class="left"><div class="date">Date sent: <?php echo date('Y/m/d H:i:s' ,$dn2['timestamp']); ?></div>
  116. <?php echo $dn2['message']; ?></td>
  117. </tr>
  118. <?php
  119. }
  120. ?>
  121. </table><br />
  122. <h2>Reply</h2>
  123. <div class="center">
  124. <form action="read_pm.php?id=<?php echo $id; ?>" method="post">
  125. <label for="message" class="center">Message</label><br />
  126. <textarea cols="40" rows="5" name="message" id="message"></textarea><br />
  127. <input type="submit" value="Send" />
  128. </form>
  129. </div>
  130. </div>
  131. <?php
  132. }
  133. }
  134. else
  135. {
  136. echo '<div class="message">You don\'t have the right to access this page.</div>';
  137. }
  138. }
  139. else
  140. {
  141. echo '<div class="message">This message doesn\'t exist.</div>';
  142. }
  143. }
  144. else
  145. {
  146. echo '<div class="message">The ID of this message is not defined.</div>';
  147. }
  148. }
  149. else
  150. {
  151. ?>
  152. <div class="message">You must be logged to access this page.</div>
  153. <div class="box_login">
  154. <form action="login.php" method="post">
  155. <label for="username">Username</label><input type="text" name="username" id="username" /><br />
  156. <label for="password">Password</label><input type="password" name="password" id="password" /><br />
  157. <label for="memorize">Remember</label><input type="checkbox" name="memorize" id="memorize" value="yes" />
  158. <div class="center">
  159. <input type="submit" value="Login" /> <input type="button" onclick="javascript:document.location='signup.php';" value="Sign Up" />
  160. </div>
  161. </form>
  162. </div>
  163. <?php
  164. }
  165. ?>
  166. <div class="foot"><a href="http://www.webestools.com/scripts_tutorials-code-source-26-simple-php-forum-script-php-forum-easy-simple-script-code-download-free-php-forum-mysql.html">Simple PHP Forum Script</a> - <a href="http://www.webestools.com/">Webestools</a></div>
  167. </body>
  168. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement