Changeset 19 for minimanager/motd.php
- Timestamp:
- Aug 13, 2007, 9:05:34 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
minimanager/motd.php
r5 r19 10 10 11 11 require_once("header.php"); 12 require_once("scripts\bbcode_lib.php"); 12 13 valid_login(1); 13 14 14 15 //##################################################################################################### 15 // print add motd16 // ADD MOTD 16 17 //##################################################################################################### 17 18 function add_motd(){ 18 global $lang_motd, $output;19 20 $output .= "<center>19 global $lang_motd, $lang_global, $output; 20 21 $output .= "<center> 21 22 <form action=\"motd.php?action=do_add_motd\" method=\"post\" name=\"form\"> 22 23 <table class=\"top_hidden\"> 24 <tr><td colspan=\"4\">"; 25 add_bbcode_editor(); 26 $output .= " </td></tr> 27 <tr><td colspan=\"4\"> 28 <textarea id=\"msg\" name=\"msg\" rows=\"10\" cols=\"93\"></textarea> 29 </td></tr> 23 30 <tr> 24 <td align=\"left\">"; 25 makebutton($lang_motd['post_motd'], "javascript:do_submit()",220); 26 $output .= "</td> 27 <td align=\"right\">{$lang_motd['post_rules']}</td> 28 </tr></table> 29 <textarea name=\"msg\" rows=\"8\" cols=\"93\"></textarea><br /> 30 </form><br /><br /> 31 <td>{$lang_motd['post_rules']}</td> 32 <td>"; 33 makebutton($lang_motd['post_motd'], "javascript:do_submit()",220); 34 $output .= " <td/><td>"; 35 makebutton($lang_global['back'], "javascript:window.history.back()",220); 36 $output .= " </td> 37 </tr> 38 </table> 39 </form> 40 <br /><br /> 31 41 </center>"; 32 42 } … … 41 51 if (empty($_POST['msg'])) redirect("motd.php?error=1"); 42 52 43 $ mysql = new MySQL;44 $ mysql->connect($mangos_db[$realm_id]['addr'], $mangos_db[$realm_id]['user'], $mangos_db[$realm_id]['pass'], $mangos_db[$realm_id]['name']);45 46 $msg = $ mysql->quote_smart($_POST['msg']);47 48 if (strlen($msg) > 254){49 $ mysql->close();53 $sql = new SQL; 54 $sql->connect($mangos_db[$realm_id]['addr'], $mangos_db[$realm_id]['user'], $mangos_db[$realm_id]['pass'], $mangos_db[$realm_id]['name']); 55 56 $msg = $sql->quote_smart($_POST['msg']); 57 58 if (strlen($msg) > 4096){ 59 $sql->close(); 50 60 redirect("motd.php?error=2"); 51 61 } 52 53 $msg = str_replace('\n', '<br />', $msg); 54 $msg = str_replace('\r', '<br />', $msg); 55 $msg = preg_replace( "/([^\/=\"\]])((http|ftp)+(s)?:\/\/[^<>\s]+)/i", "\\1<a href=\"\\2\" target=\"_blank\">\\2</a>", $msg); 56 $msg = preg_replace('/([^\/=\"\]])(www\.)(\S+)/', '\\1<a href="http://\\2\\3" target="_blank">\\2\\3</a>', $msg); 57 58 $by = date("m/d/y H:i:s")." Posted by: $user_name"; 59 60 $query = $mysql->query("INSERT INTO bugreport (type, content) VALUES ('$by','$msg')"); 61 62 $mysql->close(); 62 63 $by = date("m/d/y H:i:s")." Posted by: $user_name"; 64 65 $sql->query("INSERT INTO bugreport (type, content) VALUES ('$by','$msg')"); 66 $sql->close(); 67 68 redirect("index.php"); 69 } 70 71 //##################################################################################################### 72 // EDIT MOTD 73 //##################################################################################################### 74 function edit_motd(){ 75 global $lang_motd,$lang_global, $output, $mangos_db, $realm_id; 76 77 $sql = new SQL; 78 $sql->connect($mangos_db[$realm_id]['addr'], $mangos_db[$realm_id]['user'], $mangos_db[$realm_id]['pass'], $mangos_db[$realm_id]['name']); 79 80 if(isset($_GET['id'])) $id = $sql->quote_smart($_GET['id']); 81 else redirect("motd.php?error=1"); 82 83 $result = $sql->query("SELECT content FROM bugreport WHERE id = '$id'"); 84 $msg = $sql->result($result, 0); 85 $sql->close(); 86 87 $output .= "<center> 88 <form action=\"motd.php?action=do_edit_motd\" method=\"post\" name=\"form\"> 89 <input type=\"hidden\" name=\"id\" value=\"$id\" /> 90 <table class=\"top_hidden\"> 91 <tr><td colspan=\"4\">"; 92 add_bbcode_editor(); 93 $output .= "</td></tr> 94 <tr> 95 <td colspan=\"4\"> 96 <textarea id=\"msg\" name=\"msg\" rows=\"10\" cols=\"93\">$msg</textarea> 97 </td> 98 </tr> 99 <tr> 100 <td>{$lang_motd['post_rules']}</td> 101 <td>"; 102 makebutton($lang_motd['post_motd'], "javascript:do_submit()",220); 103 $output .= " <td/><td>"; 104 makebutton($lang_global['back'], "javascript:window.history.back()",220); 105 $output .= "</td> 106 </tr> 107 </table> 108 </form> 109 <br /><br /> 110 </center>"; 111 } 112 113 114 //##################################################################################################### 115 // DO EDIT MOTD 116 //##################################################################################################### 117 function do_edit_motd(){ 118 global $lang_global, $mangos_db, $realm_id, $user_name; 119 120 if (empty($_POST['msg']) || empty($_POST['id'])) redirect("motd.php?error=1"); 121 122 $sql = new SQL; 123 $sql->connect($mangos_db[$realm_id]['addr'], $mangos_db[$realm_id]['user'], $mangos_db[$realm_id]['pass'], $mangos_db[$realm_id]['name']); 124 125 $msg = $sql->quote_smart($_POST['msg']); 126 $id = $sql->quote_smart($_POST['id']); 127 128 $by = $sql->result($sql->query("SELECT type FROM bugreport WHERE id = '$id'"), 0, 'type'); 129 130 if (strlen($msg) > 4096){ 131 $sql->close(); 132 redirect("motd.php?error=2"); 133 } 134 135 $by = split("<br />", $by, 2); 136 $by = "{$by[0]}<br />".date("m/d/y H:i:s")." Edited by: $user_name"; 137 138 $sql->query("UPDATE bugreport SET type = '$by', content = '$msg' WHERE id = '$id'"); 139 $sql->close(); 63 140 64 141 redirect("index.php"); … … 74 151 if (empty($_GET['id'])) redirect("index.php"); 75 152 76 $ mysql = new MySQL;77 $ mysql->connect($mangos_db[$realm_id]['addr'], $mangos_db[$realm_id]['user'], $mangos_db[$realm_id]['pass'], $mangos_db[$realm_id]['name']);78 79 $id = $ mysql->quote_smart($_GET['id']);80 81 $query = $ mysql->query("DELETE FROM bugreport WHERE id ='$id'");82 83 $ mysql->close();153 $sql = new SQL; 154 $sql->connect($mangos_db[$realm_id]['addr'], $mangos_db[$realm_id]['user'], $mangos_db[$realm_id]['pass'], $mangos_db[$realm_id]['name']); 155 156 $id = $sql->quote_smart($_GET['id']); 157 158 $query = $sql->query("DELETE FROM bugreport WHERE id ='$id'"); 159 160 $sql->close(); 84 161 redirect("index.php"); 85 162 } … … 116 193 do_add_motd(); 117 194 break; 195 case "edit_motd": 196 edit_motd(); 197 break; 198 case "do_edit_motd": 199 do_edit_motd(); 200 break; 118 201 default: 119 202 add_motd();
Note:
See TracChangeset
for help on using the changeset viewer.