Bravo List
Register
Go Back   > Bravo List > Source Code > Archived Trackers > TBDev > Mods & Themes
Reply
  #1  
Old 27th March 2016, 00:15
ndbj ndbj is offline
Senior Member
 
Join Date: Dec 2012
Portugal
Posts: 35
Default Helpdesk with tickets system (corrected and improved)
Last month some guys at my tracker asked me to implement an helpdesk system, so I searched for oldstuff here, cos I'm still running an old TBDEV source, and although fully moded, I can still see this at my include/config.php:
// TBDevnet Versioning info
define ('TBVERSION',"XTBDev 0.10 Beta");


I grabbed the mod posted here
http://www.bvlist.com/showthread.php?t=1171and decided to take a look at it.

Found some errors and things without any sense and started working on correcting it, and later, improving it.

What I achieved I'll explain bellow.
In the mod posted in the link above, some people complain about:
Quote:
- box wont disappear even if i answer the ticket
- the edit button at helpdesk.php results just a white page
- when it sends the reply, the link at message doesn't leed to anywhere not to the answer anyway, just back to the helpdesk.php so that he/she can ask more stupid questions
All this are corrected.
There are now two boxes warning admins of new tickets at site and new answers to tickets.
The edit button now don't give black page.
The p.m. to user warning of the ticket reply, will have a link to right ticket.

Also, some improvements, and be aware that at my site tickets are available for answering only to class >= ADMIN
If you want that your MODERATORS can see/answer tickets as well, you'll need to change some lines.

In mod posted above, if you closed a ticket you could not see it anymore.
Ticket was at database but invisible to all, even sysops, this makes no sense.
So, you can now close a ticket by mistake, because you can also re-open it.
And after you close one, you can also delete it permanently.
When it's closed, no one can give/edit answers on it.

When creating a new ticket, you had only description.
Now you have also subject and type of ticket.
Types have small images, and you can see all tickets from some type clicking on its image, on all tickets list.
You can also change the ticket type, if you see thats wrong with the subject/description.

About closed tickets, first I made another page to browse them,
later I put closed tickets on another table below tickets at ticket list,
finaly I decided to let closed tickets among all the others,
but with small images that shows if ticket is closed or not, and also if ticket has new messages.

Helpdesk will have also a "my tickets list", cause even ADMINS can create some tickets to pass info to each others,
or MODERATORS to warn ADMINS of some problem at tracker.

Regular users will have only their ticket list available.
MODS/ADMINS will have "all tickets list" and "my tickets list" as well as "all tickets list of some ticket type".

Think that's all, hope this will be helpful to anyone!

PHP Code:
CREATE TABLE `helpdesk` (
  `
idint(10UNSIGNED NOT NULL,
  `
closedenum('yes','no'NOT NULL DEFAULT 'no',
  `
messagelongtext NOT NULL,
  `
ticketint(15NOT NULL DEFAULT '0',
  `
addeddatetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `
read_datedatetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `
useridint(11NOT NULL DEFAULT '0',
  `
edit_byint(11NOT NULL DEFAULT '0',
  `
edit_datedatetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `
subjectvarchar(255NOT NULL DEFAULT '',
  `
typevarchar(255NOT NULL DEFAULT ''
ENGINE=MyISAM DEFAULT CHARSET=latin1
PHP Code:
CREATE TABLE `readtickets` (
  `
idint(10UNSIGNED NOT NULL,
  `
useridint(10UNSIGNED NOT NULL DEFAULT '0',
  `
ticketidint(10UNSIGNED NOT NULL DEFAULT '0',
  `
lastticketreaddatetime NOT NULL DEFAULT '0000-00-00 00:00:00'
ENGINE=MyISAM DEFAULT CHARSET=utf8
helpdesk.php
PHP Code:
 <?php
ob_start
("ob_gzhandler");
require_once(
"include/bittorrent.php");
require_once(
"include/function_help.php");
dbconn();
loggedinorreturn();

    if(isset(
$_POST['action']))
    
$action $_POST['action'];
    else
    
$action "";

    if (
$action == "open_sure")
    {
    
$ticket $_POST['ticket'];
    
mysql_query("UPDATE helpdesk SET closed='No' WHERE id=$ticket") or sqlerr(__FILE____LINE__);
    
mysql_query("UPDATE helpdesk SET closed='No' WHERE ticket=$ticket") or sqlerr(__FILE____LINE__);
    }
    
    if (
$action == "close_sure")
    {
    
$ticket $_POST['ticket'];
    
mysql_query("UPDATE helpdesk SET closed='Yes' WHERE id=$ticket") or sqlerr(__FILE____LINE__);
    
mysql_query("UPDATE helpdesk SET closed='Yes' WHERE ticket=$ticket") or sqlerr(__FILE____LINE__);
    }
    if (
$action == "del_sure")
    {
    
$ticket $_POST['ticket'];
    
mysql_query("DELETE FROM helpdesk WHERE id=$ticket") or sqlerr(__FILE____LINE__);
    
mysql_query("DELETE FROM helpdesk WHERE ticket=$ticket") or sqlerr(__FILE____LINE__);
    
mysql_query("DELETE FROM readtickets WHERE ticketid=$ticket") or sqlerr(__FILE____LINE__);
    }
    
    if (
$action == "open")
    {
    
stdhead("Helpdesk");
    
page_start(98);
    
table_top("Re-open Ticket","center");
    
table_start();
    
$ticket $_POST['ticket'];
    print 
"<font size=3 color=blue>Do you really wish to re-open the ticket with id " $ticket "?";
    print 
"<br><br>";
    print 
"<table class=bottom width=30% border=0 cellspacing=0 cellpadding=4>";
    print 
"<tr>";
    print 
"<td class=embedded><div align=center>";
    print 
"<form method=post action=helpdesk.php>";
    print 
"<input type=hidden name=action value=open_sure>";
    print  
"<input type=hidden name=ticket value=".$ticket.">";
    print 
"<input type=submit class=btn style='height: 20px; width: 100px' value='Yes'>";
    print 
"</form>";
    print 
"</td>";
    print 
"<td class=embedded><div align=center>";
    print 
"<form method=post action=helpdesk.php>";
    print 
"<input type=submit class=btn style='height: 20px; width: 100px' value='No'>";
    print 
"</form>";
    print 
"</td>";
    print 
"</tr></table>";

    
table_end();
    
page_end();
    
stdfoot();
    die;
    }
    
     if (
$action == "del")
    {
    
stdhead("Helpdesk");
    
page_start(98);
    
table_top("Delete Ticket","center");
    
table_start();
    
$ticket $_POST['ticket'];
    print 
"<font size=3 color=blue>Do you really wish to delete ticket with id " $ticket "?";
    print 
"<br><br>";
    print 
"<table class=bottom width=30% border=0 cellspacing=0 cellpadding=4>";
    print 
"<tr>";
    print 
"<td class=embedded><div align=center>";
    print 
"<form method=post action=helpdesk.php>";
    print 
"<input type=hidden name=action value=del_sure>";
    print  
"<input type=hidden name=ticket value=".$ticket.">";
    print 
"<input type=submit class=btn style='height: 20px; width: 100px' value='Yes'>";
    print 
"</form>";
    print 
"</td>";
    print 
"<td class=embedded><div align=center>";
    print 
"<form method=post action=helpdesk.php>";
    print 
"<input type=submit class=btn style='height: 20px; width: 100px' value='No'>";
    print 
"</form>";
    print 
"</td>";
    print 
"</tr></table>";

    
table_end();
    
page_end();
    
stdfoot();
    die;
    }
   
    if (
$action == "close")
    {
    
stdhead("Helpdesk");
    
page_start(98);
    
table_top("Close Ticket","center");
    
table_start();
    
$ticket $_POST['ticket'];
    print 
"<font size=3 color=blue>Do you really wish to close ticket with id " $ticket "?";
    print 
"<br><br>";
    print 
"<table class=bottom width=30% border=0 cellspacing=0 cellpadding=4>";
    print 
"<tr>";
    print 
"<td class=embedded><div align=center>";
    print 
"<form method=post action=helpdesk.php>";
    print 
"<input type=hidden name=action value=close_sure>";
    print  
"<input type=hidden name=ticket value=".$ticket.">";
    print 
"<input type=submit class=btn style='height: 20px; width: 100px' value='Yes'>";
    print 
"</form>";
    print 
"</td>";
    print 
"<td class=embedded><div align=center>";
    print 
"<form method=post action=helpdesk.php>";
    print 
"<input type=submit class=btn style='height: 20px; width: 100px' value='No'>";
    print 
"</form>";
    print 
"</td>";
    print 
"</tr></table>";

    
table_end();
    
page_end();
    
stdfoot();
    die;
    }

      if (
$action == "save_edit_original")
    {
    
$ticket $_POST['ticket'];
    
$type $_POST['type'];
    if (!
$type)
    
site_error_message("Erro""Choose the problem type.");
    
mysql_query("UPDATE helpdesk SET type=$type WHERE id=$ticket") or sqlerr(__FILE____LINE__);
    }

  if (
$action == "edit_original")
    {
    
$ticket $_POST['ticket']; 
    
$type $_POST['type'];    
    
stdhead("Helpdesk - Change Ticket type");
    
page_start(98);
    
table_top("Change Ticket type","center");
    
table_start();

    
$res mysql_query("SELECT * FROM helpdesk WHERE id=$ticket") or sqlerr(__FILE____LINE__);
    
$row mysql_fetch_array($res);
    if (
$row)
        {
        
$message $row['message'];
        print 
"<table width=70% border=1 cellspacing=0 cellpadding=5>";
        print 
"<form method=post action=helpdesk.php>";
        print 
"<input type=hidden name=action value=save_edit_original>";
        print 
"<input type=hidden name=ticket value=".$ticket.">";
    print(
"<tr><td><center><b>Tipo de ticket:</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input name=\"type\" type=\"radio\" value=\"1\">&nbsp;I have a doubt\n");
    print(
"&nbsp;&nbsp;&nbsp;<input name=\"type\" type=\"radio\" value=\"2\">&nbsp;I need help\n");
    print(
"&nbsp;&nbsp;&nbsp;<input name=\"type\" type=\"radio\" value=\"3\">&nbsp;I found a problem\n");
    print(
"&nbsp;&nbsp;&nbsp;<input name=\"type\" type=\"radio\" value=\"4\">&nbsp;I have a suggestion\n");
    print(
"&nbsp;&nbsp;&nbsp;<input name=\"type\" type=\"radio\" value=\"5\">&nbsp;Others</center></td></tr>\n");
        print 
"<tr><td bgcolor=#242424><font color=white>".htmlspecialchars($message)."</font></td></tr>";
        print 
"<tr><td bgcolor=#242424 align=center><input type=submit class=btn style='height: 25px; width: 120px' value='Submit'></td></tr>";
        print 
"</table>";
        print 
"</form>";
        
        }
    
table_end();
    
page_end();
    
stdfoot();
    die;
    }
    
    if (
$action == "save_new")
    {
    
$message $_POST['message'];
    
$type $_POST['type'];
    
$subject $_POST['subject'];    
    if (!
$message)
    
site_error_message("Erro""Write the problem description.");
    if (!
$type)
    
site_error_message("Erro""Choose the ticket type.");
    if (!
$subject)
    
site_error_message("Erro""Write a subject.");    
    
$user_id $_POST['user_id'];
    
$message sqlesc($message);
    
$type sqlesc($type);
    
$subject sqlesc($subject);    
    
$added sqlesc(get_date_time());
    
$res mysql_query("SELECT * FROM helpdesk WHERE message=$message AND type=$type AND subject=$subject AND userid=$user_id") or sqlerr(__FILE____LINE__);
    
$row mysql_fetch_array($res);
    if (
$row)
    
site_error_message("Error""Fill all the fields.");
    
mysql_query("INSERT INTO helpdesk (added, userid, message, type, subject) VALUES ($added$user_id$message$type$subject)");
    }

    if (
$action == "save_edit")
    {
    
$message $_POST['message'];
    if (!
$message)
    
site_error_message("Error""Write the problem description.");
    
$ticket $_POST['ticket'];
    
$user_id $CURUSER['id'];
    
$message sqlesc($message);
    
$added sqlesc(get_date_time());
    
mysql_query("UPDATE helpdesk SET edit_by = $user_id, edit_date = $added, message = $message WHERE id=$ticket") or sqlerr(__FILE____LINE__);
    }

    if (
$action == "save_anwser")
    {
    
$message $_POST['message'];
    
$receiver $_POST['receiver'];
    if (!
$message)
    
site_error_message("Erro""Write the problem description.");
    
$user_id $_POST['user_id'];
    
$ticket $_POST['ticket'];
    
$message sqlesc($message);
    
$added sqlesc(get_date_time());
    
$res mysql_query("SELECT * FROM helpdesk WHERE message=$message AND userid=$user_id AND ticket=$ticket") or sqlerr(__FILE____LINE__);
    
$row mysql_fetch_array($res);
    if (
$row)
    
site_error_message("Error""Send a new ticket.");
    
//mysql_query("UPDATE readtickets SET lastticketread=lastticketread - 2 WHERE ticketid=$ticket") or sqlerr(__FILE__, __LINE__);
    
if ($receiver == $user_id)
    
mysql_query("INSERT INTO helpdesk (ticket, added, userid, message, read_date) VALUES ($ticket$added$user_id$message, '1111-11-11 00:00:00')") or sqlerr(__FILE____LINE__);
    else 
    {
    
mysql_query("INSERT INTO helpdesk (ticket, added, userid, message) VALUES ($ticket$added$user_id$message)") or sqlerr(__FILE____LINE__);    
    
$message "Hi " get_username($receiver) . ",\n\n";
    
$message .=    "A staff member answered your ticket.\n\n";
    
$message .=    "Use the link to check it.\n\n";
    
$message .=    $BASEURL."/tickets.php?id=".$ticket."\n\n";
    
$message .=    "Regards\n"$SITE_NAME ;    
    
$message =    sqlesc($message);
    if (
$receiver <> $user_id)    
    
mysql_query("INSERT INTO messages (sender, receiver, msg, added) VALUES (0, $receiver$message$added)") or sqlerr(__FILE____LINE__);
    }
    
        
// imagens de novas mensagens na lista de ticket - start
    
    
$addedt get_date_time();    
    
$ticketid $ticket;
    
$useronline $CURUSER['id'];
    
    
$res3 mysql_query("SELECT id, userid, ticket, added, closed FROM helpdesk WHERE id=$ticketid ORDER BY id DESC LIMIT 1") or sqlerr(__FILE____LINE__);
    
$row3 mysql_fetch_assoc($res3);
    
$hticket $row3['ticket'];
    
$hadded $row3['added'];
    
$huserid $row3['userid'];
    
$hid $row3['id'];    
    
$hclosed $row3['closed'];
    
    
$res4 mysql_query("SELECT id, userid, ticketid, lastticketread FROM readtickets WHERE ticketid=$ticketid AND userid=$useronline") or sqlerr(__FILE____LINE__);
    
$row4 mysql_fetch_assoc($res4);
    
$tread_userid $row4['userid'];
    
$tread_ticketid $row4['ticketid'];
    
$tread_lastticketread $row4['lastticketread'];
    
    
$res5 mysql_query("SELECT id, userid, ticket, added, closed FROM helpdesk WHERE ticket=$ticketid ORDER BY id DESC LIMIT 1") or sqlerr(__FILE____LINE__);
    
$row5 mysql_fetch_assoc($res5);
    
$hticket2 $row5['ticket'];
    
$hadded2 $row5['added'];
    
$huserid2 $row5['userid'];
    
$hid2 $row5['id'];    
    
$hclosed2 $row5['closed'];
            
    if (!
$tread_ticketid)
    
mysql_query("INSERT INTO readtickets (id,userid,ticketid,lastticketread) VALUES ('','$useronline','$hid','$addedt')");
    else if (
$hticket2 '0' AND $hadded2 $tread_lastticketread)
    
mysql_query("UPDATE readtickets SET lastticketread='$addedt' WHERE userid=$useronline AND ticketid=$hticket2");    
    else if (
$hadded $tread_lastticketread)
    
mysql_query("UPDATE readtickets SET lastticketread='$addedt' WHERE userid=$useronline AND ticketid=$hid");    
    }
###########################

    
if ($action == "edit")
    {
    
$ticket $_POST['ticket'];    
    
stdhead("Helpdesk - Edit Ticket answer");
    
page_start(98);
    
table_top("Edit Ticket answer","center");
    
table_start();

    
$res mysql_query("SELECT * FROM helpdesk WHERE id=$ticket") or sqlerr(__FILE____LINE__);
    
$row mysql_fetch_array($res);
    if (
$row)
        {
        
$message $row['message'];
        print 
"<font color=blue size=2><b>All questions already answered in the <a class=altlink_yellow href='faq.php'>Faq</a> page, may be<font color=red><b> ignored!</b></font></font>";
        print 
"<hr>";
        print 
"<font color=blue size=2><b>You must provide as much info as possible, for we to understand what's the problem you report.</font>";
        print 
"<hr>";
        print 
"<table width=70% border=1 cellspacing=0 cellpadding=5>";
        print 
"<form method=post action=helpdesk.php>";
        print 
"<input type=hidden name=action value=save_edit>";
        print 
"<input type=hidden name=ticket value=".$ticket.">";
        print 
"<tr><td bgcolor=#242424><textarea name=message cols=225 rows=15>".htmlspecialchars($message)."</textarea></td></tr>";
        print 
"<tr><td bgcolor=#242424 align=center><input type=submit class=btn style='height: 25px; width: 120px' value='Submit'></td></tr>";
        print 
"</table>";
        print 
"</form>";
        
        }
    
table_end();
    
page_end();
    
stdfoot();
    die;
    }
    
    if (
$action == "anwser")
    {
    
$ticket $_POST['ticket'];
    
$receiver $_POST['receiver'];
    
    
stdhead("Helpdesk");
    
page_start(98);
    
table_top("Ticket answer","center");
    
table_start();
    print 
"<table width=70% border=1 cellspacing=0 cellpadding=5>";
    
    print 
"<form name=hd_anwser method=post action=helpdesk.php>";
    print 
"<input type=hidden name=action value=save_anwser>";
    print  
"<input type=hidden name=ticket value=".$ticket.">";
    print  
"<input type=hidden name=receiver value=".$receiver.">";
    print  
"<input type=hidden name=user_id value=".$CURUSER['id'].">";
    print 
"<tr><td bgcolor=#242424><textarea name=message cols=225 rows=15></textarea></td></tr>";
    print 
"<tr><td bgcolor=#242424 align=center><input type=submit class=btn style='height: 25px; width: 120px' value='Submit'></td></tr>";
    print 
"</table>";
    print 
"</form>";
?>
<script LANGUAGE="JavaScript" type="text/javascript">
<!--
document.hd_anwser.message.focus();
//-->
</script>
<?
    
print "<br>";

    
$res mysql_query("SELECT * FROM helpdesk WHERE id=$ticket") or sqlerr(__FILE____LINE__);
    while (
$row mysql_fetch_assoc($res))
        {
        print 
"<table class=sitetable width=98% border=0 cellspacing=0 cellpadding=4>";
        print 
"<tr><td class=colheadsite>";
        print 
"Ticket - " $row['id'] . " - Answers (most recent at the top)";
        print 
"</td></tr><tr><td bgcolor=gray>";


    
$ticket $row['id'];
    
$res2 mysql_query("SELECT * FROM helpdesk WHERE closed='no' AND ticket=$ticket ORDER BY added DESC") or sqlerr(__FILE____LINE__);
    while (
$row2 mysql_fetch_assoc($res2))
        {
        print 
"<br>";
        print 
"<table class=sitetable width=100% border=0 cellspacing=0 cellpadding=4>";
        print 
"<tr>";
        print 
"<td class=colheadsite width=150>";
        print 
"Add by: <a href=userdetails.php?id=".$row2['userid']."><font color=blue>".get_username($row2['userid'])."</font></a>";
        print 
"</td>";
        print 
"<td class=colheadsite>";
        print 
"Date: " convertdate($row2['added']);
        print 
"</td>";
        print 
"</tr><tr>";
        print 
"<td class=test colspan=2>";
        
$message $row2['message'];
        if (
$row2['edit_by'] > 0)
            
$message .= "\n\n<font color=darkred> Last edition by " get_username($row2['edit_by']) . "  " convertdate($row2['edit_date']);
        print 
stripslashes(nl2br($message));
        print 
"</td></tr></table>";
        }
    
        print 
"<br><table class=sitetable width=100% border=0 cellspacing=0 cellpadding=4>";
        print 
"<tr>";
        print 
"<td class=colheadsite width=150>";
        print 
"Add by: <a href=userdetails.php?id=".$row['userid']."><font color=blue>".get_username($row['userid'])."</font></a>";
        print 
"</td>";
        print 
"<td class=colheadsite>";
        print 
"Date: " convertdate($row['added']);
        print 
"</td>";
        print 
"</tr><tr>";
        print 
"<td class=test colspan=2>";
        
$message $row['message'];
        if (
$row['edit_by'] > 0)
            
$message .= "\n\n<font color=darkred>Last edition by " get_username($row['edit_by']) . "  " convertdate($row['edit_date']);
        print 
stripslashes(nl2br($message));
        print 
"</td></tr></table>";
        print 
"</td></tr></table><br>";
        }

    
table_end();
    
page_end();
    
stdfoot();
    die;
    }

    if (
$action == "new")
    {
    
stdhead("Helpdesk");
    
page_start(98);
    
table_top("Create new ticket","center");
    
table_start();
    print 
"<font color=blue size=2><b>All questions already answered in the <a class=altlink_yellow href='faq.php'>Faq</a> page, may be<font color=red><b> ignored!</b></font></font>";
    print 
"<hr>";
    print 
"<font color=blue size=2><b>You must provide as much info as possible, for we to understand what's the problem you report.</font>";
    print 
"<hr>";
    print 
"<font color=blue size=2><b>Suggestions are always welcome.</font>";
    print 
"<hr>";
    print 
"<table width=70% border=1 cellspacing=0 cellpadding=5>";
    print 
"<form name=hd_new method=post action=helpdesk.php>";
    print 
"<input type=hidden name=action value=save_new>";
    print  
"<input type=hidden name=user_id value=".$CURUSER['id'].">";
    
    print(
"<tr><td><center><b>Ticket type:</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input name=\"type\" type=\"radio\" value=\"1\">&nbsp;I have a doubt\n");
    print(
"&nbsp;&nbsp;&nbsp;<input name=\"type\" type=\"radio\" value=\"2\">&nbsp;I need help\n");
    print(
"&nbsp;&nbsp;&nbsp;<input name=\"type\" type=\"radio\" value=\"3\">&nbsp;I found a problem\n");
    print(
"&nbsp;&nbsp;&nbsp;<input name=\"type\" type=\"radio\" value=\"4\">&nbsp;I have a suggestion\n");
    print(
"&nbsp;&nbsp;&nbsp;<input name=\"type\" type=\"radio\" value=\"5\">&nbsp;Others</center></td></tr>\n");
    
    print 
"<tr><td><center><b>Subject</b>&nbsp;<input type=text name=subject maxlength=100 size=115</center></td></tr>";
    print 
"<tr><td bgcolor=#242424><center><textarea name=message cols=125 rows=15></textarea></center></td></tr>";
    print 
"<tr><td bgcolor=#242424 align=center><input type=submit class=btn style='height: 25px; width: 120px' value='Submit'></td></tr>";
    print 
"</table>";
    print 
"</form>";
?>
<script LANGUAGE="JavaScript" type="text/javascript">
<!--
document.hd_new.message.focus();
//-->
</script>
<?
    table_end
();
    
page_end();
    
stdfoot();
    die;
    }

    
#### view ticket start
    
if ($action == "view")
    {
    
$ticket $_POST['ticket'];

    
stdhead("Helpdesk");
    
$current_user $CURUSER['id'];  
    
$count get_row_count("helpdesk""WHERE userid=$current_user");
    
    if (
get_user_class() > UC_MODERATOR)
        
$count 1;
        
    if (
$count 0)
        {
        
        
$res mysql_query("SELECT * FROM helpdesk WHERE id=$ticket") or sqlerr(__FILE____LINE__);
        while (
$row mysql_fetch_assoc($res))
            {
            print 
"<table width=80% class=bottom border=0 cellspacing=0 cellpadding=0><tr><td class=embedded><center>";
    
table_top("Ticket  « ".$row['subject']." »  criado por <a class=altlink href=userdetails.php?id=".$row['userid']."><font color=white>".get_username($row['userid'])."</a> em ".convertdate($row['added'])."","center");
            
            print(
"<p align=center><a href=#bottom class=altlink>Go to bottom</a></p>");

            print 
"<table class=sitetable width=100% border=0 cellspacing=0 cellpadding=4>"
            print 
"<tr><td bgcolor=gray>";             
            print 
"<table class=sitetable width=100% border=0 cellspacing=0 cellpadding=4>";
            print 
"<tr>";
            print 
"<td class=test width=150>";
            print 
"Send by: <a href=userdetails.php?id=".$row['userid']."><font color=blue>".get_username($row['userid'])."</font></a>";
            print 
"</td>";
            if (
$row['userid'] == $CURUSER['id'] AND $row['closed'] == 'no')
                {
                print 
"<td class=test>";
                print 
"<form method=post action=helpdesk.php>";
                print 
"<input type=hidden name=ticket value=".$row['id'].">";
                print 
"<input type=hidden name=action value=edit>";
                print 
"Date: " convertdate($row['added']);
                print 
"&nbsp;&nbsp;&nbsp;<input type=submit class=btn style='height: 20px; width: 80px' value='Edit'>";
                print 
"</form>";
                print 
"</td>";
                }
            else 
               {
                print 
"<td class=test>";
                print 
"Date: " convertdate($row['added']);
                print 
"</td>";
                }
            print 
"</tr><tr>";
            print 
"<td colspan=2 class=test>";
            
$message $row['message'];
            if (
$row['edit_by'] > 0)
                
$message .= "\n\n<font color=darkred>Last edited by " get_username($row['edit_by']) . "   " convertdate($row['edit_date']);
            print 
stripslashes(nl2br($message));
            print 
"</td></tr></table>";
                
            
$ticket $row['id'];
            
$res2 mysql_query("SELECT * FROM helpdesk WHERE ticket=$ticket ORDER BY added ASC") or sqlerr(__FILE____LINE__);
            while (
$row2 mysql_fetch_assoc($res2))
                {
                if (
$row['userid'] == $CURUSER['id'] AND $ticket $row2['id'])
                {
    
$read_date3 sqlesc(get_date_time());
    
mysql_query("UPDATE helpdesk SET read_date = $read_date3 WHERE read_date='0000-00-00 00:00:00' AND id=$ticket") or sqlerr(__FILE____LINE__);
                }        
                if (
$row['userid'] == $row2['userid'])
                
$extra_text "";
                else if (
$row2['read_date'] == "0000-00-00 00:00:00")
                
$extra_text "&nbsp;&nbsp;&nbsp;<font color=darkred>unread</font>";
                else
                
$extra_text "&nbsp;&nbsp;&nbsp;<font color=darkred>Answer read by " get_username($row['userid']) . "  " convertdate($row2['read_date']) . " </font>";
                print 
"<br>";
                print 
"<table class=sitetable width=100% border=0 cellspacing=0 cellpadding=4>";
                print 
"<tr>";
                print 
"<td class=test width=150>";
                print 
"Send by: <a href=userdetails.php?id=".$row2['userid']."><font color=blue>".get_username($row2['userid'])."</font></a>";
                print 
"</td>";
                if (
$row2['userid'] == $CURUSER['id'])
                    {
                    print 
"<td class=test>";
                    print 
"<form method=post action=helpdesk.php>";
                    print 
"<input type=hidden name=ticket value=".$row2['id'].">";
                    print 
"<input type=hidden name=action value=edit>";
                    print 
"Date: " convertdate($row2['added']) . $extra_text;
                    print 
"&nbsp;&nbsp;&nbsp;<input type=submit class=btn style='height: 20px; width: 80px' value='Edit'>";
                    print 
"</form>";
                    print 
"</td>";
                    }
                else{
                    print 
"<td class=test>";
                    print 
"Date: " convertdate($row2['added']) . $extra_text;
                    print 
"</td>";
                    }
                print 
"</tr><tr>";
                print 
"<td class=test colspan=2>";
                
$message $row2['message'];
                if (
$row2['edit_by'] > 0)
                    
$message .= "\n\n<font color=darkred>Última edição por " get_username($row2['edit_by']) . "  " convertdate($row2['edit_date']);
                print 
stripslashes(nl2br($message));
                print 
"</td></tr></table>";
                }         
            print 
"<table class=bottom width=100% border=0 cellspacing=0 cellpadding=4>";
            print 
"<tr>";
            print 
"<td class=embedded width=20%>&nbsp;</td>";
        
        if (
get_user_class() > UC_MODERATOR)
        {
        print 
"<td class=embedded>";
        print 
"<form method=post action=helpdesk.php>";
        print 
"<input type=hidden name=action value=view_my_tickets>";
        print 
"<input type=submit class=btn style='height: 28px; width: 150px' value='Check my tickets'>";
        print 
"</form>";
        print 
"</td>";
        }    
        print 
"<td class=embedded>";
        print 
"<form method=post action=helpdesk.php>";
        print 
"<input type=hidden name=action value=new>";
        print 
"<input type=submit class=btn style='height: 28px; width: 150px' value='Create new ticket'>";
        print 
"</form>"
        print 
"</td>";
        if (
get_user_class() > UC_MODERATOR)
        {
        print 
"<td class=embedded>";
        print 
"<form method=post action=helpdesk.php>";
        print 
"<input type=hidden name=action value=view_list>";
        print 
"<input type=submit class=btn style='height: 28px; width: 150px' value='Check all tickets'>";
        print 
"</form>";
        print 
"</td>";
        }            
            if (
$row['closed'] == 'no')
            {
            print 
"<td class=embedded>";
            print 
"<form method=post action=helpdesk.php>";
            print 
"<input type=hidden name=action value=anwser>";
            print  
"<input type=hidden name=receiver value=".$row['userid'].">";
            print  
"<input type=hidden name=ticket value=".$row['id'].">";
            print 
"<input type=submit class=btn style='height: 28px; width: 150px' value='Answer'>";
            print 
"</form>";
            print 
"</td>";
            }  
                if (
get_user_class() > UC_MODERATOR && $row['closed'] == 'no')
                {
                print 
"<td class=embedded>";
                print 
"<form method=post action=helpdesk.php>";
                print 
"<input type=hidden name=action value=close>";
                print 
"<input type=hidden name=ticket value=".$row['id'].">";
                print 
"<input type=submit class=btn style='height: 28px; width: 150px' value='Close'>";
                print 
"</form>";
                print 
"</td>";                
                print 
"<td class=embedded>";
                print 
"<form method=post action=helpdesk.php>";
                print 
"<input type=hidden name=ticket value=".$row['id'].">";
                print 
"<input type=hidden name=action value=edit_original>";
                print 
"<input type=submit class=btn style='height: 28px; width: 150px' value='Change ticket type'></div>";
                print 
"</form>";
                print 
"</td>";
                }                
                else if (
get_user_class() > UC_MODERATOR && $row['closed'] == 'yes')
                {
                print 
"<td class=embedded>";
                print 
"<form method=post action=helpdesk.php>";
                print 
"<input type=hidden name=action value=open>";
                print  
"<input type=hidden name=ticket value=".$row['id'].">";
                print 
"<input type=submit class=btn style='height: 28px; width: 150px' value='Re-open'>";
                print 
"</form>";
                print 
"</td>";                
                print 
"<td class=embedded>";
                print 
"<form method=post action=helpdesk.php>";
                print 
"<input type=hidden name=action value=del>";
                print  
"<input type=hidden name=ticket value=".$row['id'].">";
                print 
"<input type=submit class=btn style='height: 28px; width: 150px' value='Delete'>";
                print 
"</form>";
                print 
"</td>";            
                }  
            print 
"<td class=embedded width=20%>&nbsp;</td>";    
       
            print 
"</td></tr></table>";
            }
        }  

    print 
"</td></tr></table></table>";
    print(
"<p align=center><a href=#top class=altlink name=bottom>Back to top</a></p>");

    print 
"</td></table><br>";
    
mysql_query("UPDATE users SET last_browse=".gmtime()." where id=".$CURUSER['id']);
    
    
$addedt get_date_time();    
    
$ticketid $ticket;
    
$useronline $CURUSER['id'];
    
    
$res3 mysql_query("SELECT id, userid, ticket, added, closed FROM helpdesk WHERE id=$ticketid ORDER BY id DESC LIMIT 1") or sqlerr(__FILE____LINE__);
    
$row3 mysql_fetch_assoc($res3);
    
$hticket $row3['ticket'];
    
$hadded $row3['added'];
    
$huserid $row3['userid'];
    
$hid $row3['id'];    
    
$hclosed $row3['closed'];
    
    
$res4 mysql_query("SELECT id, userid, ticketid, lastticketread FROM readtickets WHERE ticketid=$ticketid AND userid=$useronline") or sqlerr(__FILE____LINE__);
    
$row4 mysql_fetch_assoc($res4);
    
$tread_userid $row4['userid'];
    
$tread_ticketid $row4['ticketid'];
    
$tread_lastticketread $row4['lastticketread'];
    
    
$res5 mysql_query("SELECT id, userid, ticket, added, closed FROM helpdesk WHERE ticket=$ticketid ORDER BY id DESC LIMIT 1") or sqlerr(__FILE____LINE__);
    
$row5 mysql_fetch_assoc($res5);
    
$hticket2 $row5['ticket'];
    
$hadded2 $row5['added'];
    
$huserid2 $row5['userid'];
    
$hid2 $row5['id'];    
    
$hclosed2 $row5['closed'];            
    
    if (!
$tread_ticketid AND $hticket 0)
    
mysql_query("INSERT INTO readtickets (id,userid,ticketid,lastticketread) VALUES ('','$useronline','$hticket','$addedt')");
    else if (!
$tread_ticketid)
    
mysql_query("INSERT INTO readtickets (id,userid,ticketid,lastticketread) VALUES ('','$useronline','$hid','$addedt')");

    else if (
$hticket2 '0' AND $hadded2 $tread_lastticketread)
    
mysql_query("UPDATE readtickets SET lastticketread='$addedt' WHERE userid=$useronline AND ticketid=$hticket2");    
    else if (
$hadded $tread_lastticketread)
    
mysql_query("UPDATE readtickets SET lastticketread='$addedt' WHERE userid=$useronline AND ticketid=$hid");    
    
    
stdfoot();
    die;
}    
##### view ticket end #####

##### My tickets list - admins - start #####
        
if ($action == "view_my_tickets")
            {
stdhead("Helpdesk");
print 
"<table width=70% class=bottom border=0 cellspacing=0 cellpadding=0><tr><td class=embedded><center>";
table_top("Helpdesk - Ticket system for you to make questions, report problems or give suggestions.","center");
print 
"<table background=pic/site/table_background.gif width=100% border=0 cellspacing=0 cellpadding=0>";
print 
"<tr>";
print 
"<td class=embedded align=center><center><br>";
$current_user $CURUSER['id'];

$res mysql_query("SELECT id FROM helpdesk WHERE read_date='0000-00-00 00:00:00' AND ticket='0' AND userid=$current_user") or sqlerr(__FILE____LINE__);
$row mysql_fetch_array($res);

$count get_row_count("helpdesk""WHERE ticket='0'");

    print 
"<form method=post action=helpdesk.php>";
    print 
"<input type=hidden name=action value=new>";
    print 
"<input type=submit class=btn style='height: 28px; width: 150px' value='Create new ticket'>";
    print 
"</form>";

print 
"<br></td></tr></table><br>";
print 
"</td></table>";

   print 
"<table width=70% class=bottom border=0 cellspacing=0 cellpadding=0><tr><td class=embedded><center>";
    
table_top("My tickets sent to Helpdesk - most recent at the top.","center");
    print 
"<table background=pic/site/table_background.gif width=100% border=0 cellspacing=0 cellpadding=0>";
    print 
"<tr>";
    print 
"<td class=embedded align=center><center><br>";
    
$current_user $CURUSER['id'];
    print 
"<form method=post action=helpdesk.php>";
    print 
"<input type=hidden name=action value=view_list>";
    print 
"<input type=submit class=btn style='height: 28px; width: 150px' value='Check all tickets'>";
    print 
"</form><br>";
    
$count 1;      
    if (
$count 0)
        {
        print 
"<table class=sitetable width=100% border=0 cellspacing=0 cellpadding=4>";
        print 
"<tr>";
        print 
"<td class=colhead width=50 align=center>Type</td>";
        print 
"<td class=colhead align=center>Ticket</td>";
        print 
"<td class=colhead width=50 align=center>Open</td>";
        print 
"<td class=colhead width=80 align=center>Msgs (read)</td>";
        print 
"<td class=colhead width=150 align=center>Date</td>";
        print 
"</tr>";
        
$res mysql_query("SELECT * FROM helpdesk WHERE ticket='0' AND userid=$current_user ORDER BY added DESC") or sqlerr(__FILE____LINE__);
        while (
$row mysql_fetch_assoc($res))
            {
            
$reacties get_row_count("helpdesk""WHERE ticket=".$row['id']);
            
$reacties_read get_row_count("helpdesk""WHERE read_date<>'0000-00-00 00:00:00' AND ticket=".$row['id']);
            print 
"<tr>";

               if (
$row['type'] == "1")        
$tipo = ("<img src='/pic/buttons/doubt.png' title='I have a doubt' border=0>");
         else if (
$row['type'] == "2")
$tipo = ("<img src='/pic/buttons/help.png' title='I need help' border=0>");    
        else if (
$row['type'] == "3")
$tipo = ("<img src='/pic/buttons/problem.gif' title='I found a problem' border=0>");        
        else if (
$row['type'] == "4")
$tipo = ("<img src='/pic/buttons/bulb.gif' title='I have a suggestion' border=0>");            
        else if (
$row['type'] == "5")
$tipo = ("<img src='/pic/buttons/other.gif' title='Others' border=0>");        
        else
$tipo = ("<img src=/pic/buttons/other.gif alt=" .$row["type"]. " title='Others'>");    
       
       print 
"<td class=test width=30 align=center>$tipo</td>";
            
    
$ticketid $row['id'];
    
$useronline $CURUSER['id'];
    
    
$res2 mysql_query("SELECT id, userid, ticket, added, closed FROM helpdesk WHERE id=$ticketid ORDER BY id DESC LIMIT 1") or sqlerr(__FILE____LINE__);
    
$row2 mysql_fetch_assoc($res2);
    
$hticket $row2['ticket'];
    
$huserid $row2['userid'];
    
$hid $row2['id'];    
    
$hclosed $row2['closed'];
    
$hadded $row2['added'];
    
    
$res3 mysql_query("SELECT id, userid, ticketid, lastticketread FROM readtickets WHERE ticketid=$ticketid AND userid=$useronline") or sqlerr(__FILE____LINE__);
    
$row3 mysql_fetch_assoc($res3);
    
$tread_userid $row3['userid'];
    
$tread_ticketid $row3['ticketid'];
    
$tread_lastticketread $row3['lastticketread'];
    
    
$res4 mysql_query("SELECT id, userid, ticket, added, closed FROM helpdesk WHERE ticket=$ticketid ORDER BY id DESC LIMIT 1") or sqlerr(__FILE____LINE__);
    
$row4 mysql_fetch_assoc($res4);
    
$hticket2 $row4['ticket'];
    
$huserid2 $row4['userid'];
    
$hid2 $row4['id'];    
    
$hclosed2 $row4['closed'];
    
$hadded2 $row4['added'];
    
     if (
$hticket2 '0' && $hadded2 $tread_lastticketread && $hclosed == 'yes'){
    
$ticketpic =
    (
"<form method=post action=helpdesk.php>".
    
"<input type=hidden name=action value=view>".
    
"<input type=hidden name=ticket value=".$row['id'].">".
    
"<input type=hidden name=title value='Closed ticket'>".
    
"<input type=image title='Closed ticket' img src='/pic/lockednew.gif' border=0>".
    
"</form>");}
    else if (
$hticket2 '0' && $hadded2 $tread_lastticketread && $hclosed == 'no'){
    
$ticketpic =
    (
"<form method=post action=helpdesk.php>".
    
"<input type=hidden name=action value=view>".
    
"<input type=hidden name=ticket value=".$row['id'].">".
    
"<input type=hidden name=title value='Ticket with new answers'>".
    
"<input type=image title='Ticket with new answers' img src='/pic/unlockednew.gif' border=0>".
    
"</form>");}
    else if (
$hticket2 '0' && $hadded2 <= $tread_lastticketread && $hclosed == 'yes'){
    
$ticketpic =
    (
"<form method=post action=helpdesk.php>".
    
"<input type=hidden name=action value=view>".
    
"<input type=hidden name=ticket value=".$row['id'].">".
    
"<input type=hidden name=title value='Closed ticket'>".
    
"<input type=image title='Closed ticket' img src='/pic/locked.gif' border=0>".
    
"</form>");}
    else if (
$hticket2 '0' && $hadded2 <= $tread_lastticketread && $hclosed == 'no'){
    
$ticketpic =
    (
"<form method=post action=helpdesk.php>".
    
"<input type=hidden name=action value=view>".
    
"<input type=hidden name=ticket value=".$row['id'].">".
    
"<input type=hidden name=title value='Ticket'>".
    
"<input type=image title='Ticket' img src='/pic/unlocked.gif' border=0>".
    
"</form>");}
    else if (!
$hticket2 && $hadded $tread_lastticketread && $hclosed == 'yes'){
    
$ticketpic =
    (
"<form method=post action=helpdesk.php>".
    
"<input type=hidden name=action value=view>".
    
"<input type=hidden name=ticket value=".$row['id'].">".
    
"<input type=hidden name=title value='Closed ticket'>".
    
"<input type=image title='Closed ticket' img src='/pic/lockednew.gif' border=0>".
    
"</form>");}
    else if (!
$hticket2 && $hadded $tread_lastticketread && $hclosed == 'no'){
    
$ticketpic =
    (
"<form method=post action=helpdesk.php>".
    
"<input type=hidden name=action value=view>".
    
"<input type=hidden name=ticket value=".$row['id'].">".
    
"<input type=hidden name=title value='Ticket with new answers'>".
    
"<input type=image title='Ticket with new answers' img src='/pic/unlockednew.gif' border=0>".
    
"</form>");}
    else if (!
$hticket2 && $hadded <= $tread_lastticketread && $hclosed == 'yes'){
    
$ticketpic =
    (
"<form method=post action=helpdesk.php>".
    
"<input type=hidden name=action value=view>".
    
"<input type=hidden name=ticket value=".$row['id'].">".
    
"<input type=hidden name=title value='Closed ticket'>".
    
"<input type=image title='Closed ticket' img src='/pic/locked.gif' border=0>".
    
"</form>");}
    else if (!
$hticket2 && $hadded <= $tread_lastticketread && $hclosed == 'no'){
    
$ticketpic =
    (
"<form method=post action=helpdesk.php>".
    
"<input type=hidden name=action value=view>".
    
"<input type=hidden name=ticket value=".$row['id'].">".
    
"<input type=hidden name=title value='Ticket'>".
    
"<input type=image title='Ticket' img src='/pic/unlocked.gif' border=0>".
    
"</form>");}    
    else if (!
$tread_ticketid && $hclosed == 'yes'){
    
$ticketpic =
    (
"<form method=post action=helpdesk.php>".
    
"<input type=hidden name=action value=view>".
    
"<input type=hidden name=ticket value=".$row['id'].">".
    
"<input type=hidden name=title value='Closed ticket'>".
    
"<input type=image title='Closed ticket' img src='/pic/lockednew.gif' border=0>".
    
"</form>");}
    else if (!
$tread_ticketid && $hclosed == 'no'){
    
$ticketpic =
    (
"<form method=post action=helpdesk.php>".
    
"<input type=hidden name=action value=view>".
    
"<input type=hidden name=ticket value=".$row['id'].">".
    
"<input type=hidden name=title value='Ticket with new answers'>".
    
"<input type=image title='Ticket with new answers' img src='/pic/unlockednew.gif' border=0>".
    
"</form>");}    
    else {
    
$ticketpic = ("---");}
    
           print 
"<td class=test align=left><table border=0 cellspacing=0 cellpadding=0><tr>";
            print 
"<td class=embedded><center><b><font color=darkred>".htmlspecialchars($row['subject'])."</font color></b></center><a class='altlink' href=/tickets.php?id=".$row['id']."><font color=black>". (stripslashes(substr($row['message'],0,140))) . " ---=></font color></a></td>";
            print
"</tr></table></td>";
            print 
"<td class=test align=center>$ticketpic</td>";
            print 
"<td class=test align=center>";
            print 
$reacties "&nbsp;&nbsp;<font color=red>(" $reacties_read ")</font>";
            print 
"</td>";
            print 
"<td class=test align=center>";
            print 
convertdate($row['added'])."<br>por: <a class=altlink href=/userdetails.php?id=".$row['userid'].">".get_username($row['userid']);
            print 
"</a></td>";
            print 
"</tr>";
            }
        print 
"</table>";
        }
       print 
"</td></tr></table>";
    print 
"</td></table>";
    
    
mysql_query("UPDATE users SET last_browse=".gmtime()." where id=".$CURUSER['id']);
stdfoot();
die();
    }    
##### My tickets list - admins - end #####

##### view ticket list by ticket type - start - only admins #####
        
if ($action == "view_list_type")
    {
    if (
get_user_class() > UC_MODERATOR)
            {
        
$count 1;
        
    if (
$count 0)

    
$type $_POST['type'];
    
$title $_POST['title'];
    
    
stdhead("Helpdesk");
    print 
"<table width=70% class=bottom border=0 cellspacing=0 cellpadding=0><tr><td class=embedded><center>";
    
table_top("All tickets from type: ".$title." sent to Helpdesk! - most recent at the top.","center");
    print 
"<table width=100% border=0 cellspacing=0 cellpadding=0>";
    print 
"<tr>";
    print 
"<td class=embedded align=center><center><br>";
    
$current_user $CURUSER['id'];
    
    print 
"<form method=post action=helpdesk.php>";
    print 
"<input type=hidden name=action value=view_list>";
    print 
"<input type=submit class=btn style='height: 28px; width: 150px' value='Check all tickets'>";
    print 
"</form>";
            print 
"<br>";
        print 
"<table class=sitetable width=100% border=0 cellspacing=0 cellpadding=4>";
        print 
"<tr>";
       
// print "<td class=colhead width=30 align=center>id</td>";
        
print "<td class=colhead width=50 align=center>Type</td>";
        print 
"<td class=colhead align=center>Ticket</td>";
        print 
"<td class=colhead width=50 align=center>Open</td>";
        print 
"<td class=colhead width=80 align=center>Msgs (read)</td>";
        print 
"<td class=colhead width=150 align=center>Date</td>";
        print 
"</tr>";
    
        
$res mysql_query("SELECT * FROM helpdesk WHERE ticket='0' AND type='$type' ORDER BY added DESC") or sqlerr(__FILE____LINE__);
        while (
$row mysql_fetch_assoc($res))

            {
            
$reacties get_row_count("helpdesk""WHERE ticket=".$row['id']);
            
$reacties_read get_row_count("helpdesk""WHERE read_date<>'0000-00-00 00:00:00' AND ticket=".$row['id']);
        

            print 
"<tr>";
            
             if (
$row['type'] == "1"){    
    
$tipo=
    (
"<img src='/pic/buttons/doubt.png' title='I have a doubt' border=0>");
    } else if (
$row['type'] == "2"){    
    
$tipo=
    (
"<img src='/pic/buttons/help.png' title='I need help' border=0>");
    } else if (
$row['type'] == "3"){    
    
$tipo=
    (
"<img src='/pic/buttons/problem.gif' title='I found a problem' border=0>");
    } else if (
$row['type'] == "4"){    
    
$tipo=
    (
"<img src='/pic/buttons/bulb.gif' border=0 title='I have a suggestion'>");
    } else if (
$row['type'] == "5"){    
    
$tipo=
    (
"<img src='/pic/buttons/other.gif' border=0 title='Others'>");
    } else
    
$tipo = ("<img src=/pic/buttons/other.gif alt=" .$row["type"]. " title='Others'>");    
    

              print 
"<td class=test width=30 align=center>$tipo</td>";    
            
    
$ticketid $row['id'];
    
$useronline $CURUSER['id'];
    
    
$res2 mysql_query("SELECT id, userid, ticket, added, closed FROM helpdesk WHERE id=$ticketid ORDER BY id DESC LIMIT 1") or sqlerr(__FILE____LINE__);
    
$row2 mysql_fetch_assoc($res2);
    
$hticket $row2['ticket'];
    
$huserid $row2['userid'];
    
$hid $row2['id'];    
    
$hclosed $row2['closed'];
    
$hadded $row2['added'];
    
    
$res3 mysql_query("SELECT id, userid, ticketid, lastticketread FROM readtickets WHERE ticketid=$ticketid AND userid=$useronline") or sqlerr(__FILE____LINE__);
    
$row3 mysql_fetch_assoc($res3);
    
$tread_userid $row3['userid'];
    
$tread_ticketid $row3['ticketid'];
    
$tread_lastticketread $row3['lastticketread'];
    
    
$res4 mysql_query("SELECT id, userid, ticket, added, closed FROM helpdesk WHERE ticket=$ticketid ORDER BY id DESC LIMIT 1") or sqlerr(__FILE____LINE__);
    
$row4 mysql_fetch_assoc($res4);
    
$hticket2 $row4['ticket'];
    
$huserid2 $row4['userid'];
    
$hid2 $row4['id'];    
    
$hclosed2 $row4['closed'];
    
$hadded2 $row4['added'];
    
     if (
$hticket2 '0' && $hadded2 $tread_lastticketread && $hclosed == 'yes'){
    
$ticketpic =
    (
"<form method=post action=helpdesk.php>".
    
"<input type=hidden name=action value=view>".
    
"<input type=hidden name=ticket value=".$row['id'].">".
    
"<input type=hidden name=title value='Closed ticket'>".
    
"<input type=image title='Closed ticket' img src='/pic/lockednew.gif' border=0>".
    
"</form>");}
    else if (
$hticket2 '0' && $hadded2 $tread_lastticketread && $hclosed == 'no'){
    
$ticketpic =
    (
"<form method=post action=helpdesk.php>".
    
"<input type=hidden name=action value=view>".
    
"<input type=hidden name=ticket value=".$row['id'].">".
    
"<input type=hidden name=title value='Ticket with new answers'>".
    
"<input type=image title='Ticket with new answers' img src='/pic/unlockednew.gif' border=0>".
    
"</form>");}
    else if (
$hticket2 '0' && $hadded2 <= $tread_lastticketread && $hclosed == 'yes'){
    
$ticketpic =
    (
"<form method=post action=helpdesk.php>".
    
"<input type=hidden name=action value=view>".
    
"<input type=hidden name=ticket value=".$row['id'].">".
    
"<input type=hidden name=title value='Closed ticket'>".
    
"<input type=image title='Closed ticket' img src='/pic/locked.gif' border=0>".
    
"</form>");}
    else if (
$hticket2 '0' && $hadded2 <= $tread_lastticketread && $hclosed == 'no'){
    
$ticketpic =
    (
"<form method=post action=helpdesk.php>".
    
"<input type=hidden name=action value=view>".
    
"<input type=hidden name=ticket value=".$row['id'].">".
    
"<input type=hidden name=title value='Ticket'>".
    
"<input type=image title='Ticket' img src='/pic/unlocked.gif' border=0>".
    
"</form>");}
    else if (!
$hticket2 && $hadded $tread_lastticketread && $hclosed == 'yes'){
    
$ticketpic =
    (
"<form method=post action=helpdesk.php>".
    
"<input type=hidden name=action value=view>".
    
"<input type=hidden name=ticket value=".$row['id'].">".
    
"<input type=hidden name=title value='Closed ticket'>".
    
"<input type=image title='Closed ticket' img src='/pic/lockednew.gif' border=0>".
    
"</form>");}
    else if (!
$hticket2 && $hadded $tread_lastticketread && $hclosed == 'no'){
    
$ticketpic =
    (
"<form method=post action=helpdesk.php>".
    
"<input type=hidden name=action value=view>".
    
"<input type=hidden name=ticket value=".$row['id'].">".
    
"<input type=hidden name=title value='Ticket with new answers'>".
    
"<input type=image title='Ticket with new answers' img src='/pic/unlockednew.gif' border=0>".
    
"</form>");}
    else if (!
$hticket2 && $hadded <= $tread_lastticketread && $hclosed == 'yes'){
    
$ticketpic =
    (
"<form method=post action=helpdesk.php>".
    
"<input type=hidden name=action value=view>".
    
"<input type=hidden name=ticket value=".$row['id'].">".
    
"<input type=hidden name=title value='Closed ticket'>".
    
"<input type=image title='Closed ticket' img src='/pic/locked.gif' border=0>".
    
"</form>");}
    else if (!
$hticket2 && $hadded <= $tread_lastticketread && $hclosed == 'no'){
    
$ticketpic =
    (
"<form method=post action=helpdesk.php>".
    
"<input type=hidden name=action value=view>".
    
"<input type=hidden name=ticket value=".$row['id'].">".
    
"<input type=hidden name=title value='Ticket'>".
    
"<input type=image title='Ticket' img src='/pic/unlocked.gif' border=0>".
    
"</form>");}    
    else if (!
$tread_ticketid && $hclosed == 'yes'){
    
$ticketpic =
    (
"<form method=post action=helpdesk.php>".
    
"<input type=hidden name=action value=view>".
    
"<input type=hidden name=ticket value=".$row['id'].">".
    
"<input type=hidden name=title value='Closed ticket'>".
    
"<input type=image title='Closed ticket' img src='/pic/lockednew.gif' border=0>".
    
"</form>");}
    else if (!
$tread_ticketid && $hclosed == 'no'){
    
$ticketpic =
    (
"<form method=post action=helpdesk.php>".
    
"<input type=hidden name=action value=view>".
    
"<input type=hidden name=ticket value=".$row['id'].">".
    
"<input type=hidden name=title value='Ticket with new answers'>".
    
"<input type=image title='Ticket with new answers' img src='/pic/unlockednew.gif' border=0>".
    
"</form>");}    
    else {
    
$ticketpic = ("---");}
    
            print 
"<td class=test align=left><table border=0 cellspacing=0 cellpadding=0><tr>";
            print 
"<td class=embedded><center><b><font color=darkred>".htmlspecialchars($row['subject'])."</font color></b></center><a class='altlink' href=/tickets.php?id=".$row['id']."><font color=black>". (stripslashes(substr($row['message'],0,140))) . " ---=></font color></a></td>";
            print
"</tr></table></td>";
            print 
"<td class=test align=center>$ticketpic</td>";
            print 
"<td class=test align=center>";
            print 
$reacties "&nbsp;&nbsp;<font color=red>(" $reacties_read ")</font>";
            print 
"</td>";
            print 
"<td class=test align=center>";
            print 
convertdate($row['added'])."<br>por: <a class=altlink href=/userdetails.php?id=".$row['userid'].">".get_username($row['userid']);
            print 
"</a></td>";
            print 
"</tr>";
            }
        print 
"</table>";
            }    
print 
"</td></tr></table>";
print 
"</td></table>";
    
mysql_query("UPDATE users SET last_browse=".gmtime()." where id=".$CURUSER['id']);
    
stdfoot();
    die;
    }
##### view ticket list by ticket type end - admins #####
    
##### view complete list - admins - start #####
    
if (get_user_class() > UC_MODERATOR)
            {
        
$count 1;
    
    if (
$count 0)

    
stdhead("Helpdesk");
print 
"<table width=70% class=bottom border=0 cellspacing=0 cellpadding=0><tr><td class=embedded><center>";
    
table_top("All tickets sent to Helpdesk - most recent at the top.","center");
    print 
"<table class=sitetable width=100% border=1 cellspacing=0 cellpadding=0>";
    print 
"<tr>";
    print 
"<td class=embedded align=center border=1><center><br>";
    
$current_user $CURUSER['id'];  


        print 
"<table class=sitetable width=100% border=0 cellspacing=0 cellpadding=4>";
        print 
"<tr>";
        
        print 
"<td class=embedded><p><center>";
        print 
"<form method=post action=helpdesk.php>";
        print 
"<input type=hidden name=action value=view_my_tickets>";
        print 
"<input type=submit class=btn style='height: 28px; width: 150px' value='Check my tickets'>";
        print 
"</form>";
        print 
"</center></p></td>";
        

    
        
    
//pager
$page $_GET['page'];
$perpage 10;

$respage mysql_query("SELECT COUNT(*) FROM helpdesk WHERE ticket='0'") or sqlerr(__FILE____LINE__);
$arr mysql_fetch_row($respage);
$pages floor($arr[0] / $perpage);
if (
$pages $perpage $arr[0])
  ++
$pages;

if (
$page 1)
  
$page 1;
else
  if (
$page $pages)
    
$page $pages;

for (
$i 1$i <= $pages; ++$i)
  if (
$i == $page)
    
$pagemenu .= "<b>$i</b>&nbsp;&nbsp;\n";
  else
    
$pagemenu .= "<a class= altlink href=?$q&page=$i><b>$i</b></a>&nbsp;&nbsp;\n";

if (
$page == 1)
  
$browsemenu .= "<b>&lt;&lt; Previous</b>";
else
  
$browsemenu .= "<a class= altlink href=?$q&page=" . ($page 1) . "><b>&lt;&lt; Previous</b></a>";

$browsemenu .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";

if (
$page == $pages)
  
$browsemenu .= "<b>Next &gt;&gt;</b>";
else
  
$browsemenu .= "<a class= altlink href=?$q&page=" . ($page 1) . "><b>Next &gt;&gt;</b></a>";
 

 print 
"<td class=embedded>";
 print(
"<p><center>$browsemenu<br>$pagemenu</center></p>");
 print 
"</td>";
 
  
$offset = ($page $perpage) - $perpage;
  
//pager
        
        
          
print "<td class=embedded><p><center>";
        print 
"<form method=post action=helpdesk.php>";
        print 
"<input type=hidden name=action value=new>";
        print 
"<input type=submit class=btn style='height: 28px; width: 150px' value='Create new ticket'>";
        print 
"</form>"
        print 
"</center></p></td>";
        
        print 
"</tr></table><br>";
        
        
    
//    print "<br>";
        
print "<table class=sitetable width=100% border=0 cellspacing=0 cellpadding=4>";
        print 
"<tr>";
       
// print "<td class=colhead width=30 align=center>id</td>";
        
print "<td class=colhead width=50 align=center>Type</td>";    
        print 
"<td class=colhead align=center>Ticket</td>";
        print 
"<td class=colhead width=50 align=center>Open</td>";
        print 
"<td class=colhead width=80 align=center>Msgs (read)</td>";
        print 
"<td class=colhead width=150 align=center>Date</td>";
        print 
"</tr>";
  
        
$res mysql_query("SELECT * FROM helpdesk WHERE ticket='0' ORDER BY added DESC LIMIT $offset,$perpage") or sqlerr(__FILE____LINE__);
        while (
$row mysql_fetch_assoc($res))
            {
            
$reacties get_row_count("helpdesk""WHERE ticket=".$row['id']);
            
$reacties_read get_row_count("helpdesk""WHERE read_date<>'0000-00-00 00:00:00' AND ticket=".$row['id']);
            print 
"<tr>";
        
         if (
$row['type'] == "1"){    
    
$tipo=
    (
"<form method=post action=helpdesk.php>".
    
"<input type=hidden name=action value=view_list_type>".
    
"<input type=hidden name=type value=".$row['type'].">".
    
"<input type=hidden name=title value='I have a doubt'>".
    
"<input type=image title='I have a doubt' img src='/pic/buttons/doubt.png' border=0>".
    
"</form>");
    } else if (
$row['type'] == "2"){    
    
$tipo=
    (
"<form method=post action=helpdesk.php>".
    
"<input type=hidden name=action value=view_list_type>".
    
"<input type=hidden name=type value=".$row['type'].">".
    
"<input type=hidden name=title value='I need help'>".
    
"<input type=image title='I need help' img src='/pic/buttons/help.png' border=0>".
    
"</form>");
    } else if (
$row['type'] == "3"){    
    
$tipo=
    (
"<form method=post action=helpdesk.php>".
    
"<input type=hidden name=action value=view_list_type>".
    
"<input type=hidden name=type value=".$row['type'].">".
    
"<input type=hidden name=title value='I found a problem'>".
    
"<input type=image title='I found a problem' img src='/pic/buttons/problem.gif' border=0>".
    
"</form>");
    } else if (
$row['type'] == "4"){    
    
$tipo=
    (
"<form method=post action=helpdesk.php>".
    
"<input type=hidden name=action value=view_list_type>".
    
"<input type=hidden name=type value=".$row['type'].">".
    
"<input type=hidden name=title value='I have a suggestion'>".
    
"<input type=image title='I have a suggestion' img src='/pic/buttons/bulb.gif' border=0>".
    
"</form>");
    } else if (
$row['type'] == "5"){    
    
$tipo=
    (
"<form method=post action=helpdesk.php>".
    
"<input type=hidden name=action value=view_list_type>".
    
"<input type=hidden name=type value=".$row['type'].">".
    
"<input type=hidden name=title value='Others'>".
    
"<input type=image title='Others' img src='/pic/buttons/other.gif' border=0>".
    
"</form>");
    } else
    
$tipo = ("<img src=/pic/buttons/other.gif alt=" .$row["type"]. " title='Others'>");    
        
         
//   print "<td class=test width=30 align=center>";
         //   print "<b><font color=red>".$row['id']."</font></b>";
         //   print "</td>";
            
print "<td class=test width=30 align=center>$tipo</td>";            
            
    
    
$ticketid $row['id'];
    
$useronline $CURUSER['id'];
    
    
$res2 mysql_query("SELECT id, userid, ticket, added, closed FROM helpdesk WHERE id=$ticketid ORDER BY id DESC LIMIT 1") or sqlerr(__FILE____LINE__);
    
$row2 mysql_fetch_assoc($res2);
    
$hticket $row2['ticket'];
    
$huserid $row2['userid'];
    
$hid $row2['id'];    
    
$hclosed $row2['closed'];
    
$hadded $row2['added'];
    
    
$res3 mysql_query("SELECT id, userid, ticketid, lastticketread FROM readtickets WHERE ticketid=$ticketid AND userid=$useronline") or sqlerr(__FILE____LINE__);
    
$row3 mysql_fetch_assoc($res3);
    
$tread_userid $row3['userid'];
    
$tread_ticketid $row3['ticketid'];
    
$tread_lastticketread $row3['lastticketread'];
    
    
$res4 mysql_query("SELECT id, userid, ticket, added, closed FROM helpdesk WHERE ticket=$ticketid ORDER BY id DESC LIMIT 1") or sqlerr(__FILE____LINE__);
    
$row4 mysql_fetch_assoc($res4);
    
$hticket2 $row4['ticket'];
    
$huserid2 $row4['userid'];
    
$hid2 $row4['id'];    
    
$hclosed2 $row4['closed'];
    
$hadded2 $row4['added'];
    
    if (
$hticket2 '0' && $hadded2 $tread_lastticketread && $hclosed == 'yes'){
    
$ticketpic =
    (
"<form method=post action=helpdesk.php>".
    
"<input type=hidden name=action value=view>".
    
"<input type=hidden name=ticket value=".$row['id'].">".
    
"<input type=hidden name=title value='Closed ticket'>".
    
"<input type=image title='Closed ticket' img src='/pic/lockednew.gif' border=0>".
    
"</form>");}
    else if (
$hticket2 '0' && $hadded2 $tread_lastticketread && $hclosed == 'no'){
    
$ticketpic =
    (
"<form method=post action=helpdesk.php>".
    
"<input type=hidden name=action value=view>".
    
"<input type=hidden name=ticket value=".$row['id'].">".
    
"<input type=hidden name=title value='Ticket with new answers'>".
    
"<input type=image title='Ticket with new answers' img src='/pic/unlockednew.gif' border=0>".
    
"</form>");}
    else if (
$hticket2 '0' && $hadded2 <= $tread_lastticketread && $hclosed == 'yes'){
    
$ticketpic =
    (
"<form method=post action=helpdesk.php>".
    
"<input type=hidden name=action value=view>".
    
"<input type=hidden name=ticket value=".$row['id'].">".
    
"<input type=hidden name=title value='Closed ticket'>".
    
"<input type=image title='Closed ticket' img src='/pic/locked.gif' border=0>".
    
"</form>");}
    else if (
$hticket2 '0' && $hadded2 <= $tread_lastticketread && $hclosed == 'no'){
    
$ticketpic =
    (
"<form method=post action=helpdesk.php>".
    
"<input type=hidden name=action value=view>".
    
"<input type=hidden name=ticket value=".$row['id'].">".
    
"<input type=hidden name=title value='Ticket'>".
    
"<input type=image title='Ticket' img src='/pic/unlocked.gif' border=0>".
    
"</form>");}
    else if (!
$hticket2 && $hadded $tread_lastticketread && $hclosed == 'yes'){
    
$ticketpic =
    (
"<form method=post action=helpdesk.php>".
    
"<input type=hidden name=action value=view>".
    
"<input type=hidden name=ticket value=".$row['id'].">".
    
"<input type=hidden name=title value='Closed ticket'>".
    
"<input type=image title='Closed ticket' img src='/pic/lockednew.gif' border=0>".
    
"</form>");}
    else if (!
$hticket2 && $hadded $tread_lastticketread && $hclosed == 'no'){
    
$ticketpic =
    (
"<form method=post action=helpdesk.php>".
    
"<input type=hidden name=action value=view>".
    
"<input type=hidden name=ticket value=".$row['id'].">".
    
"<input type=hidden name=title value='Ticket with new answers'>".
    
"<input type=image title='Ticket with new answers' img src='/pic/unlockednew.gif' border=0>".
    
"</form>");}
    else if (!
$hticket2 && $hadded <= $tread_lastticketread && $hclosed == 'yes'){
    
$ticketpic =
    (
"<form method=post action=helpdesk.php>".
    
"<input type=hidden name=action value=view>".
    
"<input type=hidden name=ticket value=".$row['id'].">".
    
"<input type=hidden name=title value='Closed ticket'>".
    
"<input type=image title='Closed ticket' img src='/pic/locked.gif' border=0>".
    
"</form>");}
    else if (!
$hticket2 && $hadded <= $tread_lastticketread && $hclosed == 'no'){
    
$ticketpic =
    (
"<form method=post action=helpdesk.php>".
    
"<input type=hidden name=action value=view>".
    
"<input type=hidden name=ticket value=".$row['id'].">".
    
"<input type=hidden name=title value='Ticket'>".
    
"<input type=image title='Ticket' img src='/pic/unlocked.gif' border=0>".
    
"</form>");}    
    else if (!
$tread_ticketid && $hclosed == 'yes'){
    
$ticketpic =
    (
"<form method=post action=helpdesk.php>".
    
"<input type=hidden name=action value=view>".
    
"<input type=hidden name=ticket value=".$row['id'].">".
    
"<input type=hidden name=title value='Closed ticket'>".
    
"<input type=image title='Closed ticket' img src='/pic/lockednew.gif' border=0>".
    
"</form>");}
    else if (!
$tread_ticketid && $hclosed == 'no'){
    
$ticketpic =
    (
"<form method=post action=helpdesk.php>".
    
"<input type=hidden name=action value=view>".
    
"<input type=hidden name=ticket value=".$row['id'].">".
    
"<input type=hidden name=title value='Ticket with new answers'>".
    
"<input type=image title='Ticket with new answers' img src='/pic/unlockednew.gif' border=0>".
    
"</form>");}    
    else {
    
$ticketpic = ("---");}
    
            print 
"<td class=test align=left><table border=0 cellspacing=0 cellpadding=0><tr>";
            print 
"<td class=embedded><center><b><font color=darkred>".htmlspecialchars($row['subject'])."</font color></b></center><a class='altlink' href=/tickets.php?id=".$row['id']."><font color=black>". (stripslashes(substr($row['message'],0,140))) . " ---=></font color></a></td>";
            print
"</tr></table></td>";
            print 
"<td class=test align=center>$ticketpic</td>";
            print 
"<td class=test align=center>";
            print 
$reacties "&nbsp;&nbsp;<font color=red>(" $reacties_read ")</font>";
            print 
"</td>";
            print 
"<td class=test align=center>";
            print 
convertdate($row['added'])."<br>por: <a class=altlink href=/userdetails.php?id=".$row['userid'].">".get_username($row['userid']);
            print 
"</a></td>";
            print 
"</tr>";
            }
        print 
"</table>";       
print 
"</td></tr>";
print 
"</table>";
//pager        
print("<p>$browsemenu<br>$pagemenu</p>");
$offset = ($page $perpage) - $perpage;
    
print 
"</td></table>";

    
mysql_query("UPDATE users SET last_browse=".gmtime()." where id=".$CURUSER['id']);
    
stdfoot();
    die;
    }
##### view complete list - admins - end
    
##### view complete list - users - start
    
if (get_user_class() < UC_MODERATOR)
            {
stdhead("Helpdesk");
print 
"<table width=70% class=bottom border=0 cellspacing=0 cellpadding=0><tr><td class=embedded><center>";
table_top("Helpdesk - Ticket system for you to make questions, report problems or give suggestions.","center");
print 
"<table background=pic/site/table_background.gif width=100% border=0 cellspacing=0 cellpadding=0>";
print 
"<tr>";
print 
"<td class=embedded align=center><center><br>";
$current_user $CURUSER['id'];

$res mysql_query("SELECT id FROM helpdesk WHERE read_date='0000-00-00 00:00:00' AND ticket='0' AND userid=$current_user") or sqlerr(__FILE____LINE__);
$row mysql_fetch_array($res);

$count get_row_count("helpdesk""WHERE ticket='0'");

    print 
"<form method=post action=helpdesk.php>";
    print 
"<input type=hidden name=action value=new>";
    print 
"<input type=submit class=btn style='height: 28px; width: 150px' value='Create new ticket'>";
    print 
"</form>";

print 
"<br></td></tr></table>";
print 
"</td></table>";

   print 
"<table width=70% class=bottom border=0 cellspacing=0 cellpadding=0><tr><td class=embedded><center>";
    
table_top("My tickets sent to Helpdesk - most recent at the top.","center");
    print 
"<table background=pic/site/table_background.gif width=100% border=0 cellspacing=0 cellpadding=0>";
    print 
"<tr>";
    print 
"<td class=embedded align=center><center><br>";
    
$current_user $CURUSER['id'];
    
        
$count 1;       
    if (
$count 0)
        {
        print 
"<table class=sitetable width=100% border=0 cellspacing=0 cellpadding=4>";
        print 
"<tr>";
        print 
"<td class=colhead width=50 align=center>Type</td>";
        print 
"<td class=colhead align=center>Ticket</td>";
        print 
"<td class=colhead width=50 align=center>Open</td>";
        print 
"<td class=colhead width=80 align=center>Msgs (read)</td>";
        print 
"<td class=colhead width=150 align=center>Date</td>";
        print 
"</tr>";
        
$res mysql_query("SELECT * FROM helpdesk WHERE ticket='0' AND userid=$current_user ORDER BY added DESC") or sqlerr(__FILE____LINE__);
        while (
$row mysql_fetch_assoc($res))
            {
            
$reacties get_row_count("helpdesk""WHERE ticket=".$row['id']);
            
$reacties_read get_row_count("helpdesk""WHERE read_date<>'0000-00-00 00:00:00' AND ticket=".$row['id']);
            print 
"<tr>";

         if (
$row['type'] == "1")        
$tipo = ("<img src='/pic/buttons/doubt.png' title='I have a doubt' border=0>");
         else if (
$row['type'] == "2")
$tipo = ("<img src='/pic/buttons/help.png' title='I need help' border=0>");    
        else if (
$row['type'] == "3")
$tipo = ("<img src='/pic/buttons/problem.gif' title='I found a problem' border=0>");        
        else if (
$row['type'] == "4")
$tipo = ("<img src='/pic/buttons/bulb.gif' title='I have a suggestion' border=0>");            
        else if (
$row['type'] == "5")
$tipo = ("<img src='/pic/buttons/other.gif' title='Others' border=0>");        
        else
$tipo = ("<img src=/pic/buttons/other.gif alt=" .$row["type"]. " title='Others'>");    
       
       print 
"<td class=test width=30 align=center>$tipo</td>";

            
//
    
$ticketid $row['id'];
    
$useronline $CURUSER['id'];
    
    
$res2 mysql_query("SELECT id, userid, ticket, added, closed FROM helpdesk WHERE id=$ticketid ORDER BY id DESC LIMIT 1") or sqlerr(__FILE____LINE__);
    
$row2 mysql_fetch_assoc($res2);
    
$hticket $row2['ticket'];
    
$huserid $row2['userid'];
    
$hid $row2['id'];    
    
$hclosed $row2['closed'];
    
$hadded $row2['added'];
    
    
$res3 mysql_query("SELECT id, userid, ticketid, lastticketread FROM readtickets WHERE ticketid=$ticketid AND userid=$useronline") or sqlerr(__FILE____LINE__);
    
$row3 mysql_fetch_assoc($res3);
    
$tread_userid $row3['userid'];
    
$tread_ticketid $row3['ticketid'];
    
$tread_lastticketread $row3['lastticketread'];
    
    
$res4 mysql_query("SELECT id, userid, ticket, added, closed FROM helpdesk WHERE ticket=$ticketid ORDER BY id DESC LIMIT 1") or sqlerr(__FILE____LINE__);
    
$row4 mysql_fetch_assoc($res4);
    
$hticket2 $row4['ticket'];
    
$huserid2 $row4['userid'];
    
$hid2 $row4['id'];    
    
$hclosed2 $row4['closed'];
    
$hadded2 $row4['added'];
    
   if (
$hticket2 '0' && $hadded2 $tread_lastticketread && $hclosed == 'yes'){
    
$ticketpic =
    (
"<form method=post action=helpdesk.php>".
    
"<input type=hidden name=action value=view>".
    
"<input type=hidden name=ticket value=".$row['id'].">".
    
"<input type=hidden name=title value='Closed ticket'>".
    
"<input type=image title='Closed ticket' img src='/pic/lockednew.gif' border=0>".
    
"</form>");}
    else if (
$hticket2 '0' && $hadded2 $tread_lastticketread && $hclosed == 'no'){
    
$ticketpic =
    (
"<form method=post action=helpdesk.php>".
    
"<input type=hidden name=action value=view>".
    
"<input type=hidden name=ticket value=".$row['id'].">".
    
"<input type=hidden name=title value='Ticket with new answers'>".
    
"<input type=image title='Ticket with new answers' img src='/pic/unlockednew.gif' border=0>".
    
"</form>");}
    else if (
$hticket2 '0' && $hadded2 <= $tread_lastticketread && $hclosed == 'yes'){
    
$ticketpic =
    (
"<form method=post action=helpdesk.php>".
    
"<input type=hidden name=action value=view>".
    
"<input type=hidden name=ticket value=".$row['id'].">".
    
"<input type=hidden name=title value='Closed ticket'>".
    
"<input type=image title='Closed ticket' img src='/pic/locked.gif' border=0>".
    
"</form>");}
    else if (
$hticket2 '0' && $hadded2 <= $tread_lastticketread && $hclosed == 'no'){
    
$ticketpic =
    (
"<form method=post action=helpdesk.php>".
    
"<input type=hidden name=action value=view>".
    
"<input type=hidden name=ticket value=".$row['id'].">".
    
"<input type=hidden name=title value='Ticket'>".
    
"<input type=image title='Ticket' img src='/pic/unlocked.gif' border=0>".
    
"</form>");}
    else if (!
$hticket2 && $hadded $tread_lastticketread && $hclosed == 'yes'){
    
$ticketpic =
    (
"<form method=post action=helpdesk.php>".
    
"<input type=hidden name=action value=view>".
    
"<input type=hidden name=ticket value=".$row['id'].">".
    
"<input type=hidden name=title value='Closed ticket'>".
    
"<input type=image title='Closed ticket' img src='/pic/lockednew.gif' border=0>".
    
"</form>");}
    else if (!
$hticket2 && $hadded $tread_lastticketread && $hclosed == 'no'){
    
$ticketpic =
    (
"<form method=post action=helpdesk.php>".
    
"<input type=hidden name=action value=view>".
    
"<input type=hidden name=ticket value=".$row['id'].">".
    
"<input type=hidden name=title value='Ticket with new answers'>".
    
"<input type=image title='Ticket with new answers' img src='/pic/unlockednew.gif' border=0>".
    
"</form>");}
    else if (!
$hticket2 && $hadded <= $tread_lastticketread && $hclosed == 'yes'){
    
$ticketpic =
    (
"<form method=post action=helpdesk.php>".
    
"<input type=hidden name=action value=view>".
    
"<input type=hidden name=ticket value=".$row['id'].">".
    
"<input type=hidden name=title value='Closed ticket'>".
    
"<input type=image title='Closed ticket' img src='/pic/locked.gif' border=0>".
    
"</form>");}
    else if (!
$hticket2 && $hadded <= $tread_lastticketread && $hclosed == 'no'){
    
$ticketpic =
    (
"<form method=post action=helpdesk.php>".
    
"<input type=hidden name=action value=view>".
    
"<input type=hidden name=ticket value=".$row['id'].">".
    
"<input type=hidden name=title value='Ticket'>".
    
"<input type=image title='Ticket' img src='/pic/unlocked.gif' border=0>".
    
"</form>");}    
    else if (!
$tread_ticketid && $hclosed == 'yes'){
    
$ticketpic =
    (
"<form method=post action=helpdesk.php>".
    
"<input type=hidden name=action value=view>".
    
"<input type=hidden name=ticket value=".$row['id'].">".
    
"<input type=hidden name=title value='Closed ticket'>".
    
"<input type=image title='Closed ticket' img src='/pic/lockednew.gif' border=0>".
    
"</form>");}
    else if (!
$tread_ticketid && $hclosed == 'no'){
    
$ticketpic =
    (
"<form method=post action=helpdesk.php>".
    
"<input type=hidden name=action value=view>".
    
"<input type=hidden name=ticket value=".$row['id'].">".
    
"<input type=hidden name=title value='Ticket with new answers'>".
    
"<input type=image title='Ticket with new answers' img src='/pic/unlockednew.gif' border=0>".
    
"</form>");}    
    else {
    
$ticketpic = ("---");}

            print 
"<td class=test align=left><table border=0 cellspacing=0 cellpadding=0><tr>";
            print 
"<td class=embedded><center><b><font color=darkred>".htmlspecialchars($row['subject'])."</font color></b></center><a class='altlink' href=/tickets.php?id=".$row['id']."><font color=black>". (stripslashes(substr($row['message'],0,140))) . " ---=></font color></a></td>";
            print
"</tr></table></td>";
            print 
"<td class=test align=center>$ticketpic</td>";
            print 
"<td class=test align=center>";
            print 
$reacties "&nbsp;&nbsp;<font color=red>(" $reacties_read ")</font>";
            print 
"</td>";
            print 
"<td class=test align=center>";
            print 
convertdate($row['added'])."<br>por: <a class=altlink href=/userdetails.php?id=".$row['userid'].">".get_username($row['userid']);
            print 
"</a></td>";
            print 
"</tr>";
            }
        print 
"</table>";
        }

    print 
"</td></tr></table>";
    print 
"</td></table>";

    
mysql_query("UPDATE users SET last_browse=".gmtime()." where id=".$CURUSER['id']);

stdfoot();
}
?>
tickets.php
PHP Code:
 <?php
ob_start
("ob_gzhandler");
require_once(
"include/bittorrent.php");
require_once(
"include/function_help.php");
dbconn();
loggedinorreturn();

    if(isset(
$_POST['action']))
    
$action $_POST['action'];
    else
    
$action "";

    
$action "view";
    if (
$action == "view")
    
    {
    
$id $_GET["id"];

    if (!isset(
$id) || !$id)
    die();
    
    
$ticket $id;

    
stdhead("Helpdesk");
    
$current_user $CURUSER['id'];    
    
$count get_row_count("helpdesk""WHERE userid=$current_user");
    
    if (
get_user_class() > UC_MODERATOR)
        
$count 1;
        
    if (
$count 0)
        {
        
        
$res mysql_query("SELECT * FROM helpdesk WHERE id=$ticket") or sqlerr(__FILE____LINE__);
        while (
$row mysql_fetch_assoc($res))
            {
            print 
"<table width=80% class=bottom border=0 cellspacing=0 cellpadding=0><tr><td class=embedded><center>";
    
table_top("Ticket  « ".$row['subject']." »  criado por <a class=altlink href=userdetails.php?id=".$row['userid']."><font color=white>".get_username($row['userid'])."</a> em ".convertdate($row['added'])."","center");
            
            print(
"<p align=center><a href=#bottom class=altlink>Go to bottom</a></p>");

            print 
"<table class=sitetable width=100% border=0 cellspacing=0 cellpadding=4>"
            print 
"<tr><td bgcolor=gray>";             
            print 
"<table class=sitetable width=100% border=0 cellspacing=0 cellpadding=4>";
            print 
"<tr>";
            print 
"<td class=test width=150>";
            print 
"Sent by: <a href=userdetails.php?id=".$row['userid']."><font color=blue>".get_username($row['userid'])."</font></a>";
            print 
"</td>";
            if (
$row['userid'] == $CURUSER['id'] AND $row['closed'] == 'no')
                {
                print 
"<td class=test>";
                print 
"<form method=post action=helpdesk.php>";
                print 
"<input type=hidden name=ticket value=".$row['id'].">";
                print 
"<input type=hidden name=action value=edit>";
                print 
"Date: " convertdate($row['added']);
                print 
"&nbsp;&nbsp;&nbsp;<input type=submit class=btn style='height: 20px; width: 80px' value='Edit'>";
                print 
"</form>";
                print 
"</td>";
                }
            else 
               {
                print 
"<td class=test>";
                print 
"Data: " convertdate($row['added']);
                print 
"</td>";
                }
            print 
"</tr><tr>";
            print 
"<td colspan=2 class=test>";
            
$message $row['message'];
            if (
$row['edit_by'] > 0)
                
$message .= "\n\n<font color=darkred>Last edited by " get_username($row['edit_by']) . "   " convertdate($row['edit_date']);
            print 
stripslashes(nl2br($message));
            print 
"</td></tr></table>";
                
            
$ticket $row['id'];
            
$res2 mysql_query("SELECT * FROM helpdesk WHERE ticket=$ticket ORDER BY added ASC") or sqlerr(__FILE____LINE__);
            while (
$row2 mysql_fetch_assoc($res2))
                {
        
                if (
$row['userid'] == $CURUSER['id'] AND $ticket $row2['id'])
                {
    
$read_date3 sqlesc(get_date_time());
    
mysql_query("UPDATE helpdesk SET read_date = $read_date3 WHERE read_date='0000-00-00 00:00:00' AND id=$ticket") or sqlerr(__FILE____LINE__);
                }        
                if (
$row['userid'] == $row2['userid'])
                
$extra_text "";
                else if (
$row2['read_date'] == "0000-00-00 00:00:00")
                
$extra_text "&nbsp;&nbsp;&nbsp;<font color=darkred>por ler</font>";
                else
                
$extra_text "&nbsp;&nbsp;&nbsp;<font color=darkred>Answer read by " get_username($row['userid']) . "  " convertdate($row2['read_date']) . " </font>";
                print 
"<br>";
                print 
"<table class=sitetable width=100% border=0 cellspacing=0 cellpadding=4>";
                print 
"<tr>";
                print 
"<td class=test width=150>";
                print 
"Sent by: <a href=userdetails.php?id=".$row2['userid']."><font color=blue>".get_username($row2['userid'])."</font></a>";
                print 
"</td>";
                if (
$row2['userid'] == $CURUSER['id'])
                    {
                    print 
"<td class=test>";
                    print 
"<form method=post action=helpdesk.php>";
                    print 
"<input type=hidden name=ticket value=".$row2['id'].">";
                    print 
"<input type=hidden name=action value=edit>";
                    print 
"Date: " convertdate($row2['added']) . $extra_text;
                    print 
"&nbsp;&nbsp;&nbsp;<input type=submit class=btn style='height: 20px; width: 80px' value='Edit'>";
                    print 
"</form>";
                    print 
"</td>";
                    }
                else{
                    print 
"<td class=test>";
                    print 
"Data: " convertdate($row2['added']) . $extra_text;
                    print 
"</td>";
                    }
                print 
"</tr><tr>";
                
                print 
"<td class=test colspan=2>";
                
$message $row2['message'];
                if (
$row2['edit_by'] > 0)
                    
$message .= "\n\n<font color=darkred>LAst edited by " get_username($row2['edit_by']) . "  " convertdate($row2['edit_date']);
                print 
stripslashes(nl2br($message));
                print 
"</td></tr></table>";
                }         
            print 
"<table class=bottom width=100% border=0 cellspacing=0 cellpadding=4>";
            print 
"<tr>";
            print 
"<td class=embedded width=20%>&nbsp;</td>";
        
        if (
get_user_class() > UC_MODERATOR)
        {
        print 
"<td class=embedded>";
        print 
"<form method=post action=helpdesk.php>";
        print 
"<input type=hidden name=action value=view_my_tickets>";
        print 
"<input type=submit class=btn style='height: 28px; width: 150px' value='Check my tickets'>";
        print 
"</form>";
        print 
"</td>";
        }    
        print 
"<td class=embedded>";
        print 
"<form method=post action=helpdesk.php>";
        print 
"<input type=hidden name=action value=new>";
        print 
"<input type=submit class=btn style='height: 28px; width: 150px' value='Create new ticket'>";
        print 
"</form>"
        print 
"</td>";
        if (
get_user_class() > UC_MODERATOR)
        {
        print 
"<td class=embedded>";
        print 
"<form method=post action=helpdesk.php>";
        print 
"<input type=hidden name=action value=view_list>";
        print 
"<input type=submit class=btn style='height: 28px; width: 150px' value='Check all tickets'>";
        print 
"</form>";
        print 
"</td>";
        }            
            if (
$row['closed'] == 'no')
            {
            print 
"<td class=embedded>";
            print 
"<form method=post action=helpdesk.php>";
            print 
"<input type=hidden name=action value=anwser>";
            print  
"<input type=hidden name=receiver value=".$row['userid'].">";
            print  
"<input type=hidden name=ticket value=".$row['id'].">";
            print 
"<input type=submit class=btn style='height: 28px; width: 150px' value='Answer'>";
            print 
"</form>";
            print 
"</td>";
            }  
                if (
get_user_class() > UC_MODERATOR && $row['closed'] == 'no')
                {
                print 
"<td class=embedded>";
                print 
"<form method=post action=helpdesk.php>";
                print 
"<input type=hidden name=action value=close>";
                print 
"<input type=hidden name=ticket value=".$row['id'].">";
                print 
"<input type=submit class=btn style='height: 28px; width: 150px' value='Close'>";
                print 
"</form>";
                print 
"</td>";                
                print 
"<td class=embedded>";
                print 
"<form method=post action=helpdesk.php>";
                print 
"<input type=hidden name=ticket value=".$row['id'].">";
                print 
"<input type=hidden name=action value=edit_original>";
                print 
"<input type=submit class=btn style='height: 28px; width: 150px' value='Change ticket type'></div>";
                print 
"</form>";
                print 
"</td>";
                }                
                else if (
get_user_class() > UC_MODERATOR && $row['closed'] == 'yes')
                {
                print 
"<td class=embedded>";
                print 
"<form method=post action=helpdesk.php>";
                print 
"<input type=hidden name=action value=open>";
                print  
"<input type=hidden name=ticket value=".$row['id'].">";
                print 
"<input type=submit class=btn style='height: 28px; width: 150px' value='Re-open'>";
                print 
"</form>";
                print 
"</td>";                
                print 
"<td class=embedded>";
                print 
"<form method=post action=helpdesk.php>";
                print 
"<input type=hidden name=action value=del>";
                print  
"<input type=hidden name=ticket value=".$row['id'].">";
                print 
"<input type=submit class=btn style='height: 28px; width: 150px' value='Delete'>";
                print 
"</form>";
                print 
"</td>";            
                }  
            print 
"<td class=embedded width=20%>&nbsp;</td>";    
       
            print 
"</td></tr></table>";
            }
        }  

    print 
"</td></tr></table></table>";
    print(
"<p align=center><a href=#top class=altlink name=bottom>Back to top</a></p>");

    print 
"</td></table><br>";
    
mysql_query("UPDATE users SET last_browse=".gmtime()." where id=".$CURUSER['id']);
    
    
$addedt get_date_time();    
    
$ticketid $ticket;
    
$useronline $CURUSER['id'];
    
    
$res3 mysql_query("SELECT id, userid, ticket, added, closed FROM helpdesk WHERE id=$ticketid ORDER BY id DESC LIMIT 1") or sqlerr(__FILE____LINE__);
    
$row3 mysql_fetch_assoc($res3);
    
$hticket $row3['ticket'];
    
$hadded $row3['added'];
    
$huserid $row3['userid'];
    
$hid $row3['id'];    
    
$hclosed $row3['closed'];
    
    
$res4 mysql_query("SELECT id, userid, ticketid, lastticketread FROM readtickets WHERE ticketid=$ticketid AND userid=$useronline") or sqlerr(__FILE____LINE__);
    
$row4 mysql_fetch_assoc($res4);
    
$tread_userid $row4['userid'];
    
$tread_ticketid $row4['ticketid'];
    
$tread_lastticketread $row4['lastticketread'];
    
    
$res5 mysql_query("SELECT id, userid, ticket, added, closed FROM helpdesk WHERE ticket=$ticketid ORDER BY id DESC LIMIT 1") or sqlerr(__FILE____LINE__);
    
$row5 mysql_fetch_assoc($res5);
    
$hticket2 $row5['ticket'];
    
$hadded2 $row5['added'];
    
$huserid2 $row5['userid'];
    
$hid2 $row5['id'];    
    
$hclosed2 $row5['closed'];            
    
    if (!
$tread_ticketid AND $hticket 0)
    
mysql_query("INSERT INTO readtickets (id,userid,ticketid,lastticketread) VALUES ('','$useronline','$hticket','$addedt')");
    else if (!
$tread_ticketid)
    
mysql_query("INSERT INTO readtickets (id,userid,ticketid,lastticketread) VALUES ('','$useronline','$hid','$addedt')");
    else if (
$hticket2 '0' AND $hadded2 $tread_lastticketread)
    
mysql_query("UPDATE readtickets SET lastticketread='$addedt' WHERE userid=$useronline AND ticketid=$hticket2");    
    else if (
$hadded $tread_lastticketread)
    
mysql_query("UPDATE readtickets SET lastticketread='$addedt' WHERE userid=$useronline AND ticketid=$hid");    

    
stdfoot();
    die;
}
?>
include/function_help.php
PHP Code:
<?php
function site_error_message($heading$text$color="red")
    {
    
stdhead();
    print 
"<table class=main border=1 width=60% cellpadding=0 cellspacing=0><tr><td class=embedded>";
    
table_top ($heading);
    print 
"<table background=pic/site/table_background.jpg width=100% border=1 cellspacing=0 cellpadding=10><tr><td class=embedded align=center><br>";
    print 
"<center><font size=2 color=$color><b>" $text "</b></font></center><br>";
    print 
"</td></tr></table>";
    print 
"</td></tr></table><br>";
    
stdfoot();
    die;
    }

function 
page_end()
    {
    print 
"</td></tr></table><br>\n";
    }

function 
table_end()
    {
    print 
"</td></tr></table><br>";
    print 
"</td></tr></table>";
    }

function 
table_start($width=98$cellpadding=0,$table_width=100,$paddingmain=10)
    {
    print(
"<table align=center background=pic/site/table_background.jpg width=".$table_width."% border=0 cellspacing=0 ,$paddingmain><tr><td class=embedded><br>");
    print(
"<table align=center class=bottom border=1 width=$width% cellspacing=0 cellpadding=$cellpadding><tr><td class=embedded><div align=center>");
    }

function 
page_start($width=90)
    {
    print 
"<table class=bottom width=$width% border=0 cellspacing=0 cellpadding=0><tr><td class=embedded>\n";
    }

function 
convertdate($date,$time="") { // Date function by XiniX modified by Bigjoos 2008
    
if (substr($date,5,1) == "0")
        
$month substr($date,6,1);
    else
        
$month substr($date,5,2);
    if (
substr($date,8,1) == "0")
        
$day substr($date,9,1);
    else
        
$day substr($date,8,2);
    
$year substr($date,0,4);
    if (!
$time == "no")
        
$time "  às " substr($date,11,8);
    else
        
$time "";
    if (
$month == "1") return $day " Jan " $year $time;
    if (
$month == "2") return $day " Feb " $year $time;
    if (
$month == "3") return $day " Mar " $year $time;
    if (
$month == "4") return $day " Apr " $year $time;
    if (
$month == "5") return $day " May " $year $time;
    if (
$month == "6") return $day " Jun " $year $time;
    if (
$month == "7") return $day " Jul " $year $time;
    if (
$month == "8") return $day " Aug " $year $time;
    if (
$month == "9") return $day " Sep " $year $time;
    if (
$month == "10") return $day " Oct " $year $time;
    if (
$month == "11") return $day " Nov " $year $time;
    if (
$month == "12") return $day " Dec " $year $time;
}


function 
get_username($id)
    {
    
$res mysql_query("SELECT username FROM users WHERE id = $id");
    
$row mysql_fetch_array($res);
    if (
$row)
        return 
$row['username'];
    }



function 
table_top($msg$align="",$width=100)
    {
    print 
"<table align=center class=site border=1 width=".$width."% cellpadding=2 cellspacing=2 style=background:url(mb50_3_bg.gif) repeat-x;>";
    print 
"<tr><td class=embedded>";
    print 
"<table width=100% class=bottom cellspacing=0 cellpadding=0><tr>";
    if (
$align == "")
        print 
"<td class=top_site><font size=2 color=white>&nbsp;&nbsp;$msg</td>";
    else
        print 
"<td class=top_site><font size=2 color=white><div align=" $align ">&nbsp;&nbsp;$msg&nbsp;&nbsp;</td>";
    print 
"</td></tr></table>";
    print 
"</td></tr></table>";
    }

    
/* You probably need to put this at your .css file
td.colheadsite {
  font-weight: bold;
  color: #FFFF00;
  background-color: #666666;
}
td.top_site { 
    font-weight: bold;
    font-size: 7pt;
    border: 1;
    padding: 4px;
    text-align: left;
    color: yellow;
    background: BD0000 url(mb50_3_bg.gif) repeat-x;
}
td.table_top {
    height: 35px;
    font-weight: bold;
    font-size: 9pt;
    border: 1;
    padding: 4px;
    text-align: left;
    color: #000066; 
    background: BD0000 url(mb50_3_bg.gif) repeat-x;
}
table.site {
  background-color: #303030;
  background-image: url(pic/site/table_top.gif);
  border: 1;
  border-color: #FFFFFF;
}
*/

/* You probably want to put this at your include/bittorrent.php
$reshelp = mysql_query("SELECT COUNT(id) AS ticket FROM helpdesk WHERE ticket ='0' AND closed ='no'") or sqlerr(__FILE__, __LINE__);
$arrhelp = mysql_fetch_assoc($reshelp);
$ticket = (int)$arrhelp['ticket'];
if ($ticket > 0)
$aviso = "$ticket";
//bellow the code to put at your menu (will show the open tickets at helpdesk)
print"<a href="helpdesk.php">Helpdesk <? if ($CURUSER['class'] >= UC_ADMINISTRATOR){ ?>(<?=$aviso?>)<? }?></a>";

//=== helpdesk warning
$datum[hours]=$datum[hours];
$reshelpresp = mysql_query("SELECT COUNT(id) AS new_ticket FROM helpdesk WHERE ticket ='0' AND UNIX_TIMESTAMP(added) >= ".($CURUSER['last_browse'] > gmtime() ? gmtime() : $CURUSER['last_browse'])) or sqlerr(__FILE__, __LINE__);
$arrhelpresp = mysql_fetch_assoc($reshelpresp);
$ticketresp = (int)$arrhelpresp['new_ticket'];

$datum[hours]=$datum[hours];
$reshelpresposta = mysql_query("SELECT COUNT(id) AS ticket_resposta FROM helpdesk WHERE ticket >'0' AND UNIX_TIMESTAMP(added) >= ".($CURUSER['last_browse'] > gmtime() ? gmtime() : $CURUSER['last_browse'])) or sqlerr(__FILE__, __LINE__);
$arrhelpresposta = mysql_fetch_assoc($reshelpresposta);
$ticketresposta = (int)$arrhelpresposta['ticket_resposta'];

if ($CURUSER['class'] > UC_MODERATOR AND $ticketresp) {
 ?><table border='0' cellspacing='0' cellpadding='10' align="center"><tr><td style="background:#336699 url(mb50_3_bg.gif) repeat-x;">
<a href='/helpdesk.php' title="Click to check <?php echo ($ticketresp == 1 ? '' : ''); ?>"><font color='white'><b>New tickets on helpdesk: <?php echo ($ticketresp == 1 ? '' : '').' '.$ticketresp.' '.($ticketresp > 1 ? '' : ''); ?></font></b></a>
    </td></tr></table><br><?php
}
if ($CURUSER['class'] > UC_MODERATOR AND $ticketresposta) {
 ?><table border='0' cellspacing='0' cellpadding='10' align="center"><tr><td style="background:#336699 url(mb50_3_bg.gif) repeat-x;">
<a href='/helpdesk.php' title="Click to check <?php echo ($ticketresposta == 1 ? '' : ''); ?>"><font color='white'><b>New answers to tickets: <?php echo ($ticketresposta == 1 ? '' : '').' '.$ticketresposta.' '.($ticketresposta > 1 ? '' : ''); ?></font></b></a>
    </td></tr></table><br><?php
}
//=== helpdesk warning end}

    */
?>
put this at your .css file
PHP Code:
td.colheadsite {
  
font-weightbold;
  
color#FFFF00;
  
background-color#666666;
}
td.top_site 
    
font-weightbold;
    
font-size7pt;
    
border1;
    
padding4px;
    
text-alignleft;
    
coloryellow;
    
backgroundBD0000 url(mb50_3_bg.gifrepeat-x;
}
td.table_top {
    
height35px;
    
font-weightbold;
    
font-size9pt;
    
border1;
    
padding4px;
    
text-alignleft;
    
color#000066; 
    
backgroundBD0000 url(mb50_3_bg.gifrepeat-x;
}
table.site {
  
background-color#303030;
  
background-imageurl(pic/site/table_top.gif);
  
border1;
  
border-color#FFFFFF;

and you need to put this at your include/bittorrent.php
PHP Code:
//the code to put at your menu (will show the open tickets at helpdesk)
$reshelp = mysql_query("SELECT COUNT(id) AS ticket FROM helpdesk WHERE  ticket ='0' AND closed ='no'") or sqlerr(__FILE__, __LINE__);
$arrhelp = mysql_fetch_assoc($reshelp);
$ticket = (int)$arrhelp['ticket'];
if ($ticket > 0)
$aviso = "$ticket";

print"<a  href="helpdesk.php">Helpdesk <? if ($CURUSER['class'] >=  UC_ADMINISTRATOR){ ?>(<?=$aviso?>)<? }?></a>";

//=== helpdesk warning
$datum[hours]=$datum[hours];
$reshelpresp  = mysql_query("SELECT COUNT(id) AS new_ticket FROM helpdesk WHERE  ticket ='0' AND UNIX_TIMESTAMP(added) >= ".($CURUSER['last_browse']  > gmtime() ? gmtime() : $CURUSER['last_browse'])) or sqlerr(__FILE__,  __LINE__);
$arrhelpresp = mysql_fetch_assoc($reshelpresp);
$ticketresp = (int)$arrhelpresp['new_ticket'];

$datum[hours]=$datum[hours];
$reshelpresposta  = mysql_query("SELECT COUNT(id) AS ticket_resposta FROM helpdesk WHERE  ticket >'0' AND UNIX_TIMESTAMP(added) >=  ".($CURUSER['last_browse'] > gmtime() ? gmtime() :  $CURUSER['last_browse'])) or sqlerr(__FILE__, __LINE__);
$arrhelpresposta = mysql_fetch_assoc($reshelpresposta);
$ticketresposta = (int)$arrhelpresposta['ticket_resposta'];

if ($CURUSER['class'] > UC_MODERATOR AND $ticketresp) {
 ?><table  border='0' cellspacing='0' cellpadding='10'  align="center"><tr><td style="background:#336699  url(mb50_3_bg.gif) repeat-x;">
<a href='/helpdesk.php'  title="Click to check <?php echo ($ticketresp == '' '');  ?>"><font color='white'><b>New tickets on helpdesk:  <?php echo ($ticketresp == '' '').' '.$ticketresp.'  '.($ticketresp '' ''); ?></font></b></a>
    </td></tr></table><br><?php
}
if (
$CURUSER['class'] > UC_MODERATOR AND $ticketresposta) {
 
?><table  border='0' cellspacing='0' cellpadding='10'  align="center"><tr><td style="background:#336699  url(mb50_3_bg.gif) repeat-x;">
<a href='/helpdesk.php'  title="Click to check <?php echo ($ticketresposta == '' '');  ?>"><font color='white'><b>New answers to tickets:  <?php echo ($ticketresposta == '' '').' '.$ticketresposta.'  '.($ticketresposta '' '');  ?></font></b></a>
    </td></tr></table><br><?php
}
//=== helpdesk warning end}

Finally, create a folder pics/helpdesk and throw attached images into it.
mb50_3_bg.gif should go to your route, or in config_help file change this to your needs.
PHP Code:
print "<table align=center class=site border=1 width=".$width."%  cellpadding=2 cellspacing=2 style=background:url(mb50_3_bg.gif)  repeat-x;>"
Attached Images
                   
Reply With Quote
  #2  
Old 27th March 2016, 00:44
DND DND is offline
VIP
 
Join Date: Dec 2008
Posts: 1,241
Default
OMG.. get on mysqli or pdo ASAP..
__________________
Need HELP!? I can install:

  1. Server/VPS (Debian,CentOS,Ubuntu,Fedora, FreeBSD) Optimization and ... + Modules
  2. Webserver Windows/Linux (Apache/Lighttpd/Nginx/Mysql/PhpMyAdmin/SSL) Optimization and ... + Modules
  3. Seedbox Windows/Linux (uTorrent,rTorrent,libTorrent,ruTorrent) + Modules
  4. Multiple source code engines
  5. Linux Server Administration (security, cryptography/encryption, proxy, load balancer, custom ddos firewall)
Reply With Quote
  #3  
Old 27th March 2016, 01:23
Gurkbit Gurkbit is offline
Senior Member
 
Join Date: Jun 2012
P2P
Posts: 46
Default
DND instead of all your crap posts telling all they are useless..provide your skills..show them how its supposed to be done..if you have the knowledge share it ...aint that whats bvlist is about ?.. i see your posts refering to either that site or another...ya really think a new member understands all of it..and in the end wasnt you yourself a nOOb at the start..doubt you learned all things by yourself and google
Reply With Quote
  #4  
Old 27th March 2016, 03:18
ndbj ndbj is offline
Senior Member
 
Join Date: Dec 2012
Portugal
Posts: 35
Default
Quote:
Originally Posted by DND View Post
OMG.. get on mysqli or pdo ASAP..
Call me old-fashioned, but I'm still running an old TBDEV source, older than v2008, and using Windows XP at my laptop, and they're both stable.

Also, I've had queries that crash PHP using mysqli but work just fine with the mysql package. And does the bug that made mysqli crashes on LONGTEXT columns been fixed or remains broken? I'd honestly like to use prepared statements.
Reply With Quote
  #5  
Old 27th March 2016, 13:05
joeroberts's Avatar
joeroberts joeroberts is offline
BT.Manager Owner
 
Join Date: Jan 2008
United States
Posts: 2,113
Default
I'm running mysqli on btmanager and bigjose is running it in U-232 with out and problems.
Reply With Quote
  #6  
Old 27th March 2016, 13:11
DND DND is offline
VIP
 
Join Date: Dec 2008
Posts: 1,241
Default
also running mysqli on my end and it runs like a kitten.
__________________
Need HELP!? I can install:

  1. Server/VPS (Debian,CentOS,Ubuntu,Fedora, FreeBSD) Optimization and ... + Modules
  2. Webserver Windows/Linux (Apache/Lighttpd/Nginx/Mysql/PhpMyAdmin/SSL) Optimization and ... + Modules
  3. Seedbox Windows/Linux (uTorrent,rTorrent,libTorrent,ruTorrent) + Modules
  4. Multiple source code engines
  5. Linux Server Administration (security, cryptography/encryption, proxy, load balancer, custom ddos firewall)
Reply With Quote
Reply

Tags
corrected , helpdesk , improved , system , tickets

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT +2. The time now is 07:05. vBulletin skin by ForumMonkeys. Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2024, vBulletin Solutions Inc.