Help Of my PM system

Posted on Sunday 7th September 2008 at 10:27 AM
VicVance
VicVance's Avatar
I just saw Davas and Urbans pm system, and they are very good. I want help too. I am using RMB's PM system that has no save message system or sent message system. I really need them features as they are also a main part of an PM system. I also need help on PM status I get text like unread and read, witch sucks, I need images there. Please help me on that once thats done I want help on on more thing witch Ill introduce later. this is my code.

PHP Code
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="https://www.w3.org/1999/xhtml">
  3. <head>
  4. <script>
  5. function wrapText(el, openTag, closeTag) {
  6. if (el.setSelectionRange) {
  7. // W3C/Mozilla
  8. el.value = el.value.substring(0,el.selectionStart) + openTag + el.value.substring(el.selectionStart,el.selectionEnd) + closeTag + el.value.substring(el.selectionEnd,el.value.length);
  9. }
  10. else if (document.selection && document.selection.createRange) {
  11. // IE code goes here
  12. el.focus(); //or else text is added to the activating control
  13. var range = document.selection.createRange();
  14. range.text = openTag + range.text + closeTag;
  15. }
  16. }
  17. </script>
  18. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  19. <title>Untitled Document</title>
  20. </head>
  21.  
  22. <body>
  23. <?php
  24. session_start(); //Start session
  25. if(!$logged[id]){ //Check if user is logged in
  26. header("Location: index.php?page=home&i=6");
  27. }else{ //Their loggedin
  28. switch($_GET[act]){ //make some links ?page=case
  29. default: //set up the default page upon going to pms.php
  30. $msgs = mysql_query("SELECT * FROM `privates` WHERE `to` = '" . $logged[username] . "' ORDER BY `pid` ASC") or die(mysql_error()); //get all the messages to the loged in user
  31. echo "<div align='left'><font size='4'><strong>Private Messages</strong></font>
  32. </div>
  33. </div>
  34. <table width='99%' border='0' align='center' cellpadding='0' cellspacing='0'>
  35. <tr>
  36. <td height='5' scope='col'></td>
  37. </tr>
  38. </table>
  39. <table width='100%' border='0' align='center' cellpadding='1' cellspacing='1' class='box'>
  40. <tr>
  41. <td height='21' align='left' class='row1' scope='col'>Page Location &raquo; Private Messages &raquo; In Box</td>
  42. </tr>
  43. </table>
  44. <table width='99%' border='0' align='center' cellpadding='0' cellspacing='0'>
  45. <tr>
  46. <td height='5' scope='col'></td>
  47. </tr>
  48. </table>
  49. <table width='99%' border='0' align='center' cellpadding='0' cellspacing='0'>
  50. <tr>
  51. <td height='5' scope='col'></td>
  52. </tr>
  53. </table>
  54. <table width='100%' border='0' cellpadding='2' cellspacing='1' class='box'>
  55. <tr>
  56. <td height='18' align='left' class='row2' scope='col'>Options</td>
  57. </tr>
  58. <tr>
  59. <td height='20' align='left' class='row1' scope='col'><a href="?page=pms&act=compose">&raquo; Compose Message</a></td>
  60. </tr>
  61. <tr>
  62. <td height='20' align='left' class='row1' scope='col'><a href="?page=pms&act=delall"> &raquo; Delete All Messages</a></td>
  63. </tr>
  64. </table>"; //echo the start5 table and create msg link/delete all links!
  65. if(mysql_num_rows($msgs) == 0){ //check if there are messages or not
  66. echo "<table width='99%' border='0' align='center' cellpadding='0' cellspacing='0'>
  67. <tr>
  68. <td height='5' scope='col'></td>
  69. </tr>
  70. </table>
  71. <table width='100%' border='0' cellpadding='1' cellspacing='1' class='box'>
  72. <tr>
  73. <td height='18' colspan='5' align='left' class='row2' scope='col'>In Box</td>
  74. </tr>
  75. <tr>
  76. <td width='266' height='15' class='row3' scope='col'><div align='center'>Subject </div></td>
  77. <td width='266' class='row3' scope='col'><div align='center'>From</div></td>
  78. <td width='479' class='row3' scope='col'><div align='center'>Date</div></td>
  79. <td width='266' class='row3' scope='col'><div align='center'>Status</div></td>
  80. <th width='124' class='row3' scope='col'></th>
  81. </tr>
  82. <tr>
  83. <td height='18' colspan='5' align='left' class='row1' scope='col'>You Have No New Messages!</td>
  84. </tr>
  85. </table>
  86. <table width='100%' cellpadding='0' cellspacing='0'>
  87. <tr>
  88. <td align='center' valign='middle' width='100%'>"; //no new messages
  89.  
  90. }else{ //or if there are messages
  91. echo "<table width='101%' border='0' align='center' cellpadding='0' cellspacing='0'>
  92. <tr>
  93. <td height='5' scope='col'></td>
  94. </tr>
  95. </table>";
  96. echo "<table width='100%' border='0' cellpadding='3' cellspacing='1'>
  97. <tr>
  98. <td height='5' scope='col'></td>
  99. </tr>
  100. </table>
  101. <table width='100%' border='0' cellpadding='1' cellspacing='1' class='box'>
  102. <tr>
  103. <td height='18' colspan='5' align='left' class='row2' scope='col'>In Box</td>
  104. </tr>
  105. <tr>
  106. <td width='266' height='15' class='row3' scope='col'><div align='center'>Subject </div></td>
  107. <td width='266' class='row3' scope='col'><div align='center'>From</div></td>
  108. <td width='479' class='row3' scope='col'><div align='center'>Date</div></td>
  109. <td width='266' class='row3' scope='col'><div align='center'>Status</div></td>
  110. <th width='124' class='row3' scope='col'></th>
  111. </tr>";
  112. while($r = mysql_fetch_array($msgs)){ //repeat for all the messages
  113. echo "<tr>
  114. <td align='center' class='row1' scope='col'><a href="?page=pms&act=view&id=$r[pid]">$r[subject]</a></td>
  115. <td align='center' class='row1' scope='col'><a href="members.php?user=$r[from]"><a href="members.php?user=$r[from]">$r[from]</a></td>
  116. <td align='center' class='row1' scope='col'>$r[date]</td>
  117. <td align='center' class='row1' scope='col'>$r[status]</td>
  118. <td align='center' class='row1' scope='col'><a href="?page=pms&act=delete&id=$r[pid]"><img src='images/Icons/delete.png'></a></td>
  119. </tr>"; //echo the messages
  120. } //end while
  121. } //end message amount check echo
  122. echo "</table>"; //end table
  123. error_reporting(E_ALL);
  124. $MyMessages = mysql_query("SELECT * FROM `privates` WHERE `to` = '$logged[username]' AND `status` = 'unread';");
  125. //shows the user menu
  126. $MyMessages = mysql_num_rows($MyMessages);
  127. echo "
  128. <table width='100%' border='0' cellpadding='0' cellspacing='0'>
  129. <tr>
  130. <td height='10' align='left' scope='col'></td>
  131. </tr>
  132. </table>
  133. <table width='100%' border='0' cellpadding='0' cellspacing='0' class='box'>
  134. <tr>
  135. <td height='22' align='left' class='row1' scope='col'> You have $MyMessages new message.</td>
  136. </tr>
  137. </table>
  138. ";
  139. break; //end the default page
  140. case 'view': //define the view page
  141. $id = (int)htmlspecialchars(strip_tags($_GET[id])); //make the ID safe
  142. if(!$id){ //if there is no ID to select
  143. $bbmsg = BBCODE($message);
  144. header("Location: index.php?page=pms&i=19");
  145. }else{ //or if there is....
  146. $select = mysql_query("SELECT * FROM `privates` WHERE `pid` = '" . $id . "';"); //get the message's info
  147. $msg = mysql_fetch_array($select); //select all data
  148. if($msg[to] != $logged[username]){ //check if the user logged in is the owner of the message
  149. header("Location: index.php?page=pms&i=20");
  150. }else{ //maybe...
  151. if(!$_POST[reply]) { //if the reply was not submitted
  152. $mark = mysql_query("UPDATE `privates` SET `status` = 'Read' WHERE `pid` = '" . $id . "'") or die(mysql_error()); //mark it as Read
  153. $message = nl2br(stripslashes($msg[content])); //make new lines to and strip the slashes
  154. $subject = stripslashes($msg[subject]); //strip the slashes
  155. $date = date("F j, Y, g:i a"); //the date sent
  156. echo"<div align='left'><font size='4'><strong>Private Messages</strong></font>
  157. </div>
  158. <table width='99%' border='0' align='center' cellpadding='0' cellspacing='0'>
  159. <tr>
  160. <td height='5' scope='col'></td>
  161. </tr>
  162. </table>
  163. <table width='100%' border='0' align='center' cellpadding='1' cellspacing='1' class='box'>
  164. <tr>
  165. <td height='21' align='left' class='row1' scope='col'>Page Location &raquo; Private Messages &raquo; Viewing Messages</td>
  166. </tr>
  167. </table>
  168. <table width='99%' border='0' align='center' cellpadding='0' cellspacing='0'>
  169. <tr>
  170. <td height='5' scope='col'></td>
  171. </tr>
  172. </table>
  173. <table width='99%' border='0' align='center' cellpadding='0' cellspacing='0'>
  174. <tr>
  175. <td height='5' scope='col'></td>
  176. </tr>
  177. </table>
  178. <table width='100%' border='0' align='center' cellpadding='0' cellspacing='0'>
  179. <tr>
  180. <td height='5' scope='col'>
  181. <form method="post">
  182. <table width='100%' border='0' align='center' cellpadding='1' cellspacing='1' class='box'>
  183. <tr>
  184. <td height='18' colspan='3' align='left' class='row2' scope='col'> <IMG height='6' src='images/bullet.gif' width='4'> <span class='forum_text'>$subject</span></td>
  185. </tr>
  186. <tr>
  187. <td width='24%' height='12' align='left' class='row3' scope='col'>$msg[from]</td>
  188. <td colspan='2' align='left' class='row3' scope='col'><div align='right'>$date </div></td>
  189. </tr>
  190. <tr>
  191. <td height='16' align='left' class='row1' scope='col'>";{
  192. if ($user[userlevel] == 6)
  193. {
  194. echo ("<img src="images/titles/icon4.bmp">");
  195. }
  196. elseif ($user[userlevel] == 4)
  197. {
  198. echo ("<img src="images/titles/icon1.bmp">");
  199. }
  200. else
  201. {
  202. echo ("<img src="images/titles/icon5.bmp">");
  203. }
  204. }
  205. echo "</td>
  206. <td width='65%' align='left' class='row1' scope='col'> $message</td>
  207. <td width='11%' align='left' class='row1' scope='col'></td>
  208. </tr>
  209. <tr>
  210. <td height='10' align='left' class='row1' scope='col'></td>
  211. <td align='left' class='row1' scope='col'></td>
  212. <td align='left' class='row1' scope='col'></td>
  213. </tr>
  214. </table>
  215. <table width='99%' border='0' align='center' cellpadding='0' cellspacing='0'>
  216. <tr>
  217. <td height='5' scope='col'></td>
  218. </tr>
  219. </table>
  220. <table width='100%' border='0' cellpadding='1' cellspacing='1' class='box'>
  221. <tr>
  222. <td height='18' colspan='3' align='left' class='row2' scope='col'>Add Reply</td>
  223. </tr>
  224. <tr>
  225. <td colspan='3' align='right' class='row3' scope='col'><a href='?page=bbcode'>BB Code Help?</a></td>
  226. </tr>
  227. <tr>
  228. <td width='23%' align='left' valign='bottom' class='row1' scope='col'><div align='left'><font size='1'>
  229. <div align='center'>$emotion</div>
  230. </div>
  231. <div align='left'><font size='1'> BBcode<FONT COLOR='green'> &raquo; Enabled </font></div>
  232. <div align='left'><font size='1'> Smileys<FONT COLOR='green'> &raquo; Enabled </font></div></td>
  233. <td width='77%' colspan='2' align='left' class='row1' scope='col'><center>$tags</center>
  234. <center>
  235. <textarea id="TheTextArea" name="msg"2 cols="45" rows="6" class='input'></textarea></td>
  236. </tr>
  237. <tr>
  238. <td colspan='3' align='left' class='row1' scope='col'><input name="reply" type="submit" class='boxbutton' value="Reply"></td>
  239. </tr>
  240. </table>
  241. <table width='99%' border='0' align='center' cellpadding='0' cellspacing='0'>
  242. <tr>
  243. <td height='5' scope='col'></td>
  244. </tr>
  245. </table>
  246. <table width='100%' border='0' align='center' cellpadding='1' cellspacing='1' class='box'>
  247. <tr>
  248. <td height='21' align='left' class='row1' scope='col'><a href='index.php?page=pms'>Go Back?</a></td>
  249. </tr>
  250. </table>
  251. </form ></td>
  252. </tr>
  253. </table>"; //echo the message and reply box.
  254. }else{ //if the form was submitted
  255. $to = $msg[from]; //get who it is to
  256. $from = $logged[username]; //who its from
  257. $subject = "RE: " . $msg[subject]; //new subject
  258. $msg = addslashes($_POST[msg]); //the content
  259. $date = date("F j, Y, g:i a"); //the date sent
  260. $do = mysql_query("INSERT INTO `privates` (`to`,`from`,`date`,`subject`,`content`) VALUES ('" . $to . "','" . $from . "','" . $date . "','" . $subject . "','" . $msg . "')") or die(mysql_error()); //insert into the table!
  261. header("Location: index.php?page=pms&i=21");
  262. } //end reply check
  263. } //end check posession
  264. } //end id check
  265. break;
  266.  
  267. case 'compose': //create a new message
  268. echo "<div align='left'><font size='4'><strong>Private Messages</strong></font>
  269. </div>
  270. <table width='99%' border='0' align='center' cellpadding='0' cellspacing='0'>
  271. <tr>
  272. <td height='5' scope='col'></td>
  273. </tr>
  274. </table>
  275. <table width='100%' border='0' align='center' cellpadding='1' cellspacing='1' class='box'>
  276. <tr>
  277. <td height='21' align='left' class='row1' scope='col'>Page Location &raquo; Private Messages &raquo; Compose Message</td>
  278. </tr>
  279. </table>
  280. <table width='99%' border='0' align='center' cellpadding='0' cellspacing='0'>
  281. <tr>
  282. <td height='5' scope='col'></td>
  283. </tr>
  284. </table>
  285. <table width='99%' border='0' align='center' cellpadding='0' cellspacing='0'>
  286. <tr>
  287. <td height='5' scope='col'></td>
  288. </tr>
  289. </table>";
  290. echo " <table width='100%' border='0' align='center' cellpadding='1' cellspacing='1' class='box'>";
  291. if(!$_POST[send]){ //if the form was not submitted
  292. echo "<form method="post" action="">
  293. <tr>
  294. <td height='20' colspan='2' align='left' class='row2' scope='row'>Compose Message.</td>
  295. </tr>"; //echo some of the form and whatnot
  296. if(isset($_GET[user])){ //check if there is a user in the address bar
  297. echo "<tr>
  298. <td colspan='2' align='left' class='row1' scope='row'>&raquo; To User
  299. <input class='input' type="text" name="to" value="$_GET[user]" size="15">
  300. <span class='imp'>* Provided </span></td>
  301. </tr>";
  302. }else{ //or not..
  303. echo "<tr>
  304. <td colspan='2' align='left' class='row1' scope='row'>&raquo; To User
  305. <input class='input' type="text" name="to" size="15">
  306. <span class='imp'>* Required </span></td>
  307. </tr>"; //echo the input box without the value of the user!
  308. } //end user check in address bar
  309. echo "<form>
  310. <tr>
  311. <td width='17%' align='left' class='row1' scope='col'>&raquo; Subject:</td>
  312. <td width='83%' align='left' class='row1' scope='col'>
  313. &nbsp;&nbsp;&nbsp;&nbsp;<input name="title" type="text" class='input' value="Unitiled Message" size="15" Message> </td>
  314. </tr>
  315. <tr>
  316. <td width='22%' align='left' class='row1' scope='row'>&raquo; Content</td>
  317. <td width='83%' align='left' class='row1' scope='row'><div align='right'><a href='?page=bbcode'>BB Code Help?</a></div></td>
  318. </tr>
  319. <tr>
  320. <td width='17%' valign='bottom' class='row1' scope='col'><div align='left'><font size='1'>
  321. <div align='center'>$emotion</div>
  322. </div>
  323. <div align='left'><font size='1'><FONT COLOR='green'><A href='?page=bbcode'>BBcode</A> &raquo; Enabled </font></div>
  324. <div align='left'><font size='1'><FONT COLOR='green'><A href='?page=bbcode'>Smileys</A> &raquo; Enabled </font></div></td>
  325. <td width='83%' class='row1' scope='col'><center>
  326. $tags
  327. <textarea id="TheTextArea" name="message" cols="45" rows="6" class='input'></textarea>
  328. <br><div style='padding-left: 5px; padding-top:5px;'>
  329. </tr>
  330. <tr>
  331. <td colspan='2' align='left' class='row1' scope='row'><input name="send" type="submit" class='boxbutton' value="Send Message"> </td>
  332. </tr>
  333. </form>"; //echo the rest of the form
  334. echo "<table width='99%' border='0' align='center' cellpadding='0' cellspacing='0'>
  335. <tr>
  336. <td height='5' scope='col'></td>
  337. </tr>";
  338. echo "<table width='100%' border='0' align='center' cellpadding='1' cellspacing='1' class='box'>
  339. <tr>
  340. <td height='21' align='left' class='row1' scope='col'><a href='index.php?page=pms'>Go Back?</a></td>
  341. </tr>";
  342. echo "</table>";
  343. }else{ //or if it was..
  344. echo "</table>";
  345. echo "</table>";
  346. echo "</table>";
  347.  
  348. $to = stripslashes(htmlspecialchars(strip_tags($_POST[to]))); //who its to
  349. $from = $logged[username]; //who its from
  350. $date = date("F j, Y, g:i a"); //the date sent
  351. $msg = addslashes($_POST[message]); //the message variable
  352. $subject = addslashes($_POST[title]); //the subject
  353. $do = mysql_query("INSERT INTO `privates` (`to`,`from`,`date`,`subject`,`content`) VALUES ('" . $to . "','" . $from . "','" . $date . "','" . $subject . "','" . $msg . "')") or die(mysql_error()); //insert into the table!
  354. header("Location: index.php?page=pms&i=21");
  355. } //end sent check
  356. break; //end make new msg
  357. case 'delall': //delete all page
  358. $get = mysql_query("SELECT * FROM `privates` WHERE `to` = '" . $logged[username] . "'"); //get the private messages
  359. if(mysql_num_rows($get) == "0"){
  360. header("Location: index.php?page=pms&i=23");
  361. }else{
  362. $delete = mysql_query("DELETE FROM `privates` WHERE `to` = '" . $logged[username] . "'"); //delete tehm
  363. if($delete) { //check if theres a mySQL error
  364. header("Location: index.php?page=pms&i=22"); //success
  365. }else{ //or not
  366. header("Location: index.php?page=pms&i=24");
  367. } //end error check
  368. } //end msg check
  369. break; //end page
  370. case 'delete': //start the delete page!
  371. $id = (int)htmlspecialchars(strip_tags($_GET[id])); //make the ID safe
  372. if(!$id){ //if there is no ID to select
  373. echo "<a href="?page=pms">Go Back</a>No ID Selected!"; //echo the error
  374. }else{ //or if there is....
  375. $select = mysql_query("SELECT * FROM `privates` WHERE `pid` = '" . $id . "'"); //get the message's info
  376. $msg = mysql_fetch_array($select); //select all data
  377. if($msg[to] != $logged[username]){ //check if the user logged in is the owner of the message
  378. header("Location: index.php?page=pms&i=20"); //if not
  379. }else{ //maybe...
  380. $do = mysql_query("DELETE FROM `privates` WHERE `pid` = '" . $id . "'") or die(mysql_error());
  381. header("Location: index.php?page=pms&i=25");
  382. } //end check possession
  383. } //end id check
  384. break; //end the delete page!
  385. } //end switch/get
  386. } //end login check
  387. ?>
  388. </body>
  389. </html>
Posted on Sunday 7th September 2008 at 02:23 PM
ShadowMage
ShadowMage's Avatar
I think Dava was going to place his as a tutorial :3 Not sure.
failure i sense
Posted on Monday 8th September 2008 at 11:27 AM
Dava
Dava's Avatar
once my pm system is bug free and all features are inplace i will be posting the complete thing
Dava
Login or register to respond to this forum topic.