wMan |
6th February 2009 00:23 |
helpdesk
any one know how to add bbcode to this pls :sos:
PHP Code:
<?php /********************************************************************************\ * * * ---------------------------------------------------------------------------- * * H E L P D E S K * * (for TB source) * * ---------------------------------------------------------------------------- * * written by nuerher[at]gmail.com * \********************************************************************************/ ob_start("ob_gzhandler");
function round_time($ts) { $mins = floor($ts / 60); $hours = floor($mins / 60); $mins -= $hours * 60; $days = floor($hours / 24); $hours -= $days * 24; $weeks = floor($days / 7); $days -= $weeks * 7; $t = ""; if ($weeks > 0) return "$weeks week" . ($weeks > 1 ? "s" : ""); if ($days > 0) return "$days day" . ($days > 1 ? "s" : ""); if ($hours > 0) return "$hours hour" . ($hours > 1 ? "s" : ""); if ($mins > 0) return "$mins min" . ($mins > 1 ? "s" : ""); return "< 1 min"; }
require_once("include/bittorrent.php"); dbconn(false); loggedinorreturn();
$msg_problem = trim($_POST["msg_problem"]); $msg_answer = trim($_POST["msg_answer"]); $id = $_POST["id"]; $addedbyid = $_POST["addedbyid"]; $title = trim($_POST["title"]);
$action = $_GET["action"]; $solve = $_GET["solve"];
// --- action: cleanuphd if ($action == 'cleanuphd') { mysql_query("DELETE FROM helpdesk WHERE solved='yes' OR solved='ignored'"); $action = 'problems'; } // --- action: problems
if ($action == 'problems') {
if (get_user_class() < UC_MODERATOR) { stdmsg("Sorry...", "You are not authorized to enter this site."); stdfoot(); exit; }
// Standard HD Replies // English $hd_reply['1'] = array("Read FAQ","First read the [url=faq.php][b]FAQ[/b][/url] and then start asking questions!"); $hd_reply['2'] = array("Search forums","Search the [url=forums.php][b]FORUMS[/b][/url] please."); $hd_reply['3'] = array("Die n00b","Die n00b! Such a thing knows even my grandma!");
// POST & GET $id = $_GET["id"]; $hd_answer=$_POST["hd_answer"]; if ($hd_answer) { $body = $hd_reply[$hd_answer][1]; }
stdhead("HELP DESK - Problems"); begin_main_frame(); begin_frame("Problems");
// VIEW PROBLEM DETAILS if ($id != 0) {
$res = mysql_query("SELECT * FROM helpdesk WHERE id = $id"); $arr = mysql_fetch_array($res);
$zap = mysql_query("SELECT username FROM users WHERE id = $arr[added_by]"); $wyn = mysql_fetch_array($zap);
$added_by_name = $wyn["username"];
$zap_s = mysql_query("SELECT username FROM users WHERE id = $arr[solved_by]"); $wyn_s = mysql_fetch_array($zap_s);
$solved_by_name = $wyn_s["username"];
print("<table align=center border=1 cellpadding=5 cellspacing=0>". "<tr><td align=center colspan=2 class=colhead>".$arr["title"]."</td></tr>". "<tr><td align=right><b>Added</b></td><td align=left>On <b>".$arr["added"]."</b> by <a href=userdetails.php?id=".$arr["added_by"]."><b>".$added_by_name."</b></a></td></tr>");
if ($arr["solved"] == 'yes') {
print("<tr><td align=right><b>Problem</b></td><td align=left><textarea name=msg_problem cols=80 rows=15>".$arr["msg_problem"]."</textarea></td></tr>". "<tr><td align=right><b>Solved</b></td><td align=left><font color=green><b>Yes</b></font> on <b>".$arr["solved_date"]."</b> by <a href=userdetails.php?id=".$arr["solved_by"]."><b>".$solved_by_name."</b></a></td></tr>". "<tr><td align=right><b>Answer</b></td><td align=left><textarea name=msg_answer cols=80 rows=15>".$arr["msg_answer"]."</textarea></td></tr></table>");
} else if ($arr["solved"] == 'ignored') {
print("<tr><td align=right><b>Problem</b></td><td align=left><textarea name=msg_problem cols=80 rows=15>".$arr["msg_problem"]."</textarea></td></tr>". "<tr><td align=right><b>Solved</b></td><td align=left><font color=orange><b>Ignored</b></font> on <b>".$arr["solved_date"]."</b> by <a href=userdetails.php?id=".$arr["solved_by"]."><b>".$solved_by_name."</b></a></td></tr>". "</table>");
} else if ($arr["solved"] == 'no') {
$addedbyid = $arr["added_by"];
print("<form method=post action=helpdesk.php><tr><td><tr><td align=right><b>Problem</b></td><td align=left><textarea name=msg_problem cols=80 rows=15>".$arr["msg_problem"]."</textarea></td></tr>". "<tr><td align=right><b>Solved</b></td><td align=center><font color=red><b>No</b></font>". "<tr><td align=right><b>Answer</b></td><td><textarea name=msg_answer cols=80 rows=15>$body</textarea><br/>(<a href=tags.php><b>BB code</b></a> is allowed.)<input type=hidden name=id value=$id><input type=hidden name=addedbyid value=$addedbyid></td></tr>". "<tr><td colspan=2 align=center><input type=submit value=Answer! class=btn> <b>||</b> <a href=helpdesk.php?action=solve&pid=$id&solved=ignored><font color=red><b>IGNORE</b></font></a></td></tr></form></table>");
} }
// VIEW PROBLEMS else {
print("<table align=center border=1 cellpadding=5 cellspacing=0><td class=colhead align=center>Added</td><td class=colhead align=center>Added by</td><td class=colhead align=center>Problem</td><td class=colhead align=center>Solved - by</td><td class=colhead align=center>Solved in*</td></tr>");
$res = mysql_query("SELECT * FROM helpdesk ORDER BY added DESC"); while($arr = mysql_fetch_array($res)) {
$zap = mysql_query("SELECT username FROM users WHERE id = $arr[added_by]"); $wyn = mysql_fetch_array($zap);
$added_by_name = $wyn["username"];
$zap_s = mysql_query("SELECT username FROM users WHERE id = $arr[solved_by]"); $wyn_s = mysql_fetch_array($zap_s);
$solved_by_name = $wyn_s["username"];
// SOLVED IN $added = $arr["added"]; $solved_date = $arr["solved_date"];
if ($solved_date == "0000-00-00 00:00:00") { $solved_in = " [N/A]"; $solved_color = "black"; } else { $solved_in_wtf = sql_timestamp_to_unix_timestamp($arr["solved_date"]) - sql_timestamp_to_unix_timestamp($arr["added"]); $solved_in = " [".round_time($solved_in_wtf)."]";
if ($solved_in_wtf > 2*3600) { $solved_color = "red"; } else if ($solved_in_wtf > 3600) { $solved_color = "black"; } else if ($solved_in_wtf <= 1800) { $solved_color = "green"; }
}
print("<tr><td>".$arr["added"]."</td>". "<td><a href=userdetails.php?id=".$arr["added_by"].">".$added_by_name."</a></td>". "<td><a href=helpdesk.php?action=problems&id=".$arr["id"]."><b>".$arr["title"]."</b></a></td>");
if ($arr["solved"] == 'no') { $solved_by = "N/A"; print("<td><font color=red><b>No</b></font> - ".$solved_by."</td>"); } else if ($arr["solved"] == 'yes') { $solved_by = "<a href=userdetails.php?id=".$arr["solved_by"].">".$solved_by_name."</a>"; print("<td><font color=green><b>Yes</b></font> - ".$solved_by."</td>"); } else if ($arr["solved"] == 'ignored') { $solved_by = "<a href=userdetails.php?id=".$arr["solved_by"].">".$solved_by_name."</a>"; print("<td><font color=orange><b>Ignored</b></font> - ".$solved_by."</td>"); }
print("<td><font color=".$solved_color.">".$solved_in."</font></td></tr>");
}
print("<tr><td align=center class=colhead colspan=5><form method=get action=?><input type=hidden name=action value=cleanuphd><input type=submit value='Delete solved or ignored problems' style='height:20;align:center;'></form></tr></table>"); print("". "<font color=green>[ xx ]</font> - great, ". "<font color=black>[ xx ]</font> - ok, ". "<font color=red>[ xx ]</font> - bad"); }
end_frame(); end_main_frame();
if ($arr["solved"] == 'no') {
print("". "<form method=post action=helpdesk.php?action=problems&id=$id>"); ?> <table align="center" border="1" cellspacing="0" cellpadding="5"> <tr><td> <b>HD Replies:</b> <select name="hd_answer"><? for ($i = 1; $i <= count($hd_reply); $i++) { echo "<option value=$i ".($hd_answer == $i?"selected":""). ">".$hd_reply[$i][0]."</option>\n"; }?> </select> <input type="submit" value="Use" class="btn"> </td></tr></table></form> <?
}
print("</table>"); stdfoot(); exit;
}
// Main FILE
stdhead("Help Desk"); begin_main_frame();
if ($action == 'solve') {
$pid = $_GET["pid"]; if ($solve = 'ignored') { $dt = sqlesc(get_date_time()); mysql_query("UPDATE helpdesk SET solved='ignored', solved_by=$CURUSER[id], solved_date = $dt WHERE id=$pid"); } }
if (($msg_answer != "") && ($id != 0)){
$zap_usr = mysql_query("SELECT username FROM users WHERE id = $addedbyid"); $wyn_usr = mysql_fetch_array($zap_usr);
$addedby_name = $wyn_usr["username"];
$msg = sqlesc("[color=blue][b]==[ HELP DESK ]==[/b][/color]\n\n[quote=".$addedby_name."]".$msg_problem."[/quote]\n".$msg_answer."\n\nregards");
$dt = sqlesc(get_date_time()); mysql_query("UPDATE helpdesk SET solved='yes', solved_by=$CURUSER[id], solved_date = $dt, msg_answer = ".sqlesc($msg_answer)." WHERE id=$id"); // mysql_query("INSERT INTO messages ( mysql_query("INSERT INTO messages (sender, receiver, added, msg, poster,unread) VALUES($CURUSER[id], $addedbyid, $dt, $msg, $CURUSER[id],'yes')");
stdmsg("Help desk","<b>Problem ID:</b> $idAnswer:<textarea name=msg_answer cols=80 rows=15>$msg</textarea><b>Solved by: ".$CURUSER["id"]."</b>STATUS: <b>SOLVED</b>"); end_main_frame(); stdfoot(); exit;
}
if (($msg_problem != "") && ($title != "")){
$dt = sqlesc(get_date_time()); mysql_query("INSERT INTO helpdesk (title, msg_problem, added, added_by) VALUES (".sqlesc($title).", ".sqlesc($msg_problem).", $dt, $CURUSER[id])") or sqlerr();
// mysql_query("INSERT INTO helpdesk (added) VALUES ($dt)") or sqlerr();
stdmsg("Help desk", "Message sent! Await for reply."); end_main_frame(); stdfoot(); exit; }
// ----- MAIN HELP DESK ---------
if (get_user_class() >= UC_MODERATOR) { print("<center><a href=helpdesk.php?action=problems><h1>PROBLEMS</h1></a></center><br/>"); } ?> <!-- ENGLISH --> <center><font color=red size=2><blockquote>Before using <b>Help Desk</b> make sure to read <a href=faq.php><b>FAQ</b></a> and search <a href=forums.php><b>Forums</b></a> first.</blockquote></font><br/></center> <center><h1>HELP DESK</h1></center> <center><font color="red" size="2"><b>( -- BETA -- )</b></font></center><br/>
<form method="post" action="helpdesk.php"> <table border="0" align="center" cellpadding="5" cellspacing="0"> <tr> <td align="right"> <b>TITLE:</b></td> <td align="left"><input type="text" size="73" maxlength="60" name="title"></td> </tr> <!-- <tr> <td align="left" colspan="2"></td> </tr> --> <tr> <td colspan="2"><textarea name="msg_problem" cols="80" rows="15"><?php print($msg_problem);?></textarea><!--(<a href=tags.php class=altlink>BB</a> tags are <b>allowed</b>.)--></td> </tr> <tr> <td align="center" colspan="2"><input type="submit" value="Help me!" class="btn"></td> </tr> </table> </form>
<?php end_main_frame(); stdfoot(); ?>
|