Postado Junho 30, 2014 10 anos Vi alguns sistemas de helpdesk sendo postados aqui no fórum e para aprender um pouco mais resolvi montar um bem simples para o ZnoteACC que achei um projeto incrivel e com um código muito fácil de trabalhar, enfim vamos ao que interessa ScreenShots: Rode os seguintes comandos SQL para criar as tabelas e colunas necessárias para o funcionamento do sistema: CREATE TABLE IF NOT EXISTS `znote_tickets` ( `id` int(11) NOT NULL AUTO_INCREMENT, `owner` int(11) NOT NULL, `username` varchar(32) CHARACTER SET latin1 NOT NULL, `subject` text CHARACTER SET latin1 NOT NULL, `message` text CHARACTER SET latin1 NOT NULL, `ip` int(11) NOT NULL, `creation` int(11) NOT NULL, `status` varchar(20) CHARACTER SET latin1 NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; CREATE TABLE IF NOT EXISTS `znote_tickets_replies` ( `id` int(11) NOT NULL AUTO_INCREMENT, `tid` int(11) NOT NULL, `username` varchar(32) CHARACTER SET latin1 NOT NULL, `message` text CHARACTER SET latin1 NOT NULL, `created` int(11) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; Crie o arquivo helpdesk.php na raiz com o seguinte conteúdo: <?php require_once 'engine/init.php'; if (user_logged_in() === false) { header('Location: register.php'); } include 'layout/overall/header.php'; $view = (int)$_GET['view']; if ($view) { if (!empty($_POST['reply_text'])) { sanitize($_POST['reply_text']); // Save ticket reply on database $query = array( 'tid' => $_GET['view'], 'username'=> $_POST['username'], 'message' => $_POST['reply_text'], 'created' => time(), ); //Sanitize array array_walk($query, 'array_sanitize'); $fields = '`'. implode('`, `', array_keys($query)) .'`'; $data = '\''. implode('\', \'', $query) .'\''; mysql_insert("INSERT INTO `znote_tickets_replies` ($fields) VALUES ($data)"); mysql_update("UPDATE `znote_tickets` SET `status`='Player-Reply' WHERE `id`=". $_GET['view']); } $ticketData = mysql_select_single("SELECT * FROM znote_tickets WHERE id=". addslashes((int)$_GET['view'])); if($ticketData['owner'] != $session_user_id){ echo 'You can not view this ticket!'; die; } ?> <h1>View Ticket #<?php echo $ticketData['id']; ?></h1> <table class="znoteTable ThreadTable table table-striped"> <tr class="yellow"> <th> <?php echo getClock($ticketData['creation'], true); ?> - Created by: <?php echo $ticketData['username']; ?> </th> </tr> <tr> <td> <p><?php echo nl2br($ticketData['message']); ?></p> </td> </tr> </table> <?php $replies = mysql_select_multi("SELECT * FROM znote_tickets_replies WHERE tid='". (int)$_GET['view'] ."' ORDER BY `created`;"); if ($replies !== false) { foreach($replies as $reply) { ?> <table class="znoteTable ThreadTable table table-striped"> <tr class="yellow"> <th> <?php echo getClock($reply['created'], true); ?> - Posted by: <?php echo $reply['username']; ?> </th> </tr> <tr> <td> <p><?php echo nl2br($reply['message']); ?></p> </td> </tr> </table> <hr class="bighr"> <?php } } ?> <form action="" method="post"> <input type="hidden" name="username" value="<?php echo $ticketData['username']; ?>"><br> <textarea class="forumReply" name="reply_text" style="width: 610px; height: 150px"></textarea><br> <input name="" type="submit" value="Post Reply" class="btn btn-primary"> </form> <?php }else{ $account = mysql_select_single("SELECT name,email FROM accounts WHERE id = $session_user_id"); if (empty($_POST) === false) { // $_POST[''] $required_fields = array('username', 'email', 'subject', 'message'); foreach($_POST as $key=>$value) { if (empty($value) && in_array($key, $required_fields) === true) { $errors[] = 'You need to fill in all fields.'; break 1; } } // check errors (= user exist, pass long enough if (empty($errors) === true) { /* Token used for cross site scripting security */ if (!Token::isValid($_POST['token'])) { $errors[] = 'Token is invalid.'; } if ($config['use_captcha']) { include_once 'captcha/securimage.php'; $securimage = new Securimage(); if ($securimage->check($_POST['captcha_code']) == false) { $errors[] = 'Captcha image verification was submitted wrong.'; } } if (validate_ip(getIP()) === false && $config['validate_IP'] === true) { $errors[] = 'Failed to recognize your IP address. (Not a valid IPv4 address).'; } } } ?> <h1>Latest Tickets</h1> <?php $tickets = mysql_select_multi("SELECT id,subject,creation,status FROM znote_tickets WHERE owner=$session_user_id ORDER BY creation DESC"); if ($tickets !== false) { ?> <table> <tr class="yellow"> <td>ID:</td> <td>Subject:</td> <td>Creation:</td> <td>Status:</td> </tr> <?php foreach ($tickets as $ticket) { echo '<tr class="special">'; echo '<td>'. $ticket['id'] .'</td>'; echo '<td><a href="helpdesk.php?view='. $ticket['id'] .'">'. $ticket['subject'] .'</a></td>'; echo '<td>'. getClock($ticket['creation'], true) .'</td>'; echo '<td>'. $ticket['status'] .'</td>'; }} ?> </table> <h1>Helpdesk</h1> <?php if (isset($_GET['success']) && empty($_GET['success'])) { echo 'Congratulations! Your ticket has been created. We will reply up to 24 hours.'; } else { if (empty($_POST) === false && empty($errors) === true) { if ($config['log_ip']) { znote_visitor_insert_detailed_data(1); } //Save ticket on database $query = array( 'owner' => $session_user_id, 'username'=> $_POST['username'], 'subject' => $_POST['subject'], 'message' => $_POST['message'], 'ip' => ip2long(getIP()), 'creation' => time(), 'status' => 'Open' ); //Sanitize array array_walk($query, 'array_sanitize'); $fields = '`'. implode('`, `', array_keys($query)) .'`'; $data = '\''. implode('\', \'', $query) .'\''; mysql_insert("INSERT INTO `znote_tickets` ($fields) VALUES ($data)"); header('Location: helpdesk.php?success'); exit(); } else if (empty($errors) === false){ echo '<font color="red"><b>'; echo output_errors($errors); echo '</b></font>'; } ?> <form action="" method="post"> <ul> <li> Account Name:<br> <input type="text" name="username" size="40" value="<?php echo $account['name']; ?>" disabled> </li> <li> Email:<br> <input type="text" name="email" size="40" value="<?php echo $account['email']; ?>" disabled> </li> <li> Subject:<br> <input type="text" name="subject" size="40"> </li> <li> Message:<br> <textarea name="message" rows="7" cols="30"></textarea> </li> <?php if ($config['use_captcha']) { ?> <li> <b>Write the image symbols in the text field to verify that you are a human:</b> <img id="captcha" src="captcha/securimage_show.php" alt="CAPTCHA Image" /><br> <input type="text" name="captcha_code" size="10" maxlength="6" /> <a href="#" onclick="document.getElementById('captcha').src = 'captcha/securimage_show.php?' + Math.random(); return false">[ Different Image ]</a><br><br> </li> <?php } ?> <?php /* Form file */ Token::create(); ?> <li> <input type="hidden" name="username" value="<?php echo $account['name']; ?>"> <input type="submit" value="Submit ticket"> </li> </ul> </form> <?php }} include 'layout/overall/footer.php'; ?> Crie o arquivo admin_helpdesk.php com o conteúdo abaixo: <?php require_once 'engine/init.php'; include 'layout/overall/header.php'; protect_page(); admin_only($user_data); // Declare as int $view = (int)$_GET['view']; if ($view){ if (!empty($_POST['reply_text'])) { sanitize($_POST['reply_text']); // Save ticket reply on database $query = array( 'tid' => $_GET['view'], 'username'=> $_POST['username'], 'message' => $_POST['reply_text'], 'created' => time(), ); //Sanitize array array_walk($query, 'array_sanitize'); $fields = '`'. implode('`, `', array_keys($query)) .'`'; $data = '\''. implode('\', \'', $query) .'\''; mysql_insert("INSERT INTO `znote_tickets_replies` ($fields) VALUES ($data)"); mysql_update("UPDATE `znote_tickets` SET `status`='Staff-Reply' WHERE `id`=". $_GET['view']); } $ticketData = mysql_select_single("SELECT * FROM znote_tickets WHERE id=". addslashes((int)$_GET['view'])); ?> <h1>View Ticket #<?php echo $ticketData['id']; ?></h1> <table class="znoteTable ThreadTable table table-striped"> <tr class="yellow"> <th> <?php echo getClock($ticketData['creation'], true); ?> - Created by: <?php echo $ticketData['username']; ?> </th> </tr> <tr> <td> <p><?php echo nl2br($ticketData['message']); ?></p> </td> </tr> </table> <?php $replies = mysql_select_multi("SELECT * FROM znote_tickets_replies WHERE tid='". addslashes((int)$_GET['view']) ."' ORDER BY `created`;"); if ($replies !== false) { foreach($replies as $reply) { ?> <table class="znoteTable ThreadTable table table-striped"> <tr class="yellow"> <th> <?php echo getClock($reply['created'], true); ?> - Posted by: <?php echo $reply['username']; ?> </th> </tr> <tr> <td> <p><?php echo nl2br($reply['message']); ?></p> </td> </tr> </table> <hr class="bighr"> <?php } } ?> <form action="" method="post"> <input type="hidden" name="username" value="ADMIN"><br> <textarea class="forumReply" name="reply_text" style="width: 610px; height: 150px"></textarea><br> <input name="" type="submit" value="Post Reply" class="btn btn-primary"> </form> <?php }else{ ?> <h1>Latest Tickets</h1> <?php $tickets = mysql_select_multi("SELECT id,subject,creation,status FROM znote_tickets ORDER BY creation DESC"); if ($tickets !== false) { ?> <table> <tr class="yellow"> <td>ID:</td> <td>Subject:</td> <td>Creation:</td> <td>Status:</td> </tr> <?php foreach ($tickets as $ticket) { echo '<tr class="special">'; echo '<td>'. $ticket['id'] .'</td>'; echo '<td><a href="admin_helpdesk.php?view='. $ticket['id'] .'">'. $ticket['subject'] .'</a></td>'; echo '<td>'. getClock($ticket['creation'], true) .'</td>'; echo '<td>'. $ticket['status'] .'</td>'; }} ?> </table> <?php } include 'layout/overall/footer.php'; ?> Para adicionar o Helpdesk no menu edite o arquivo /layout/menu.php e troque isto: <li><a href="market.php">Item Market</a></li> <li><a href="gallery.php">Gallery</a></li> <li><a href="support.php">Support</a></li> <li><a href="houses.php">Houses</a></li> <li><a href="deaths.php">Deaths</a></li> <li><a href="killers.php">Killers</a></li> Por isso: <li><a href="market.php">Item Market</a></li> <li><a href="gallery.php">Gallery</a></li> <li><a href="support.php">Support</a></li> <li><a href="helpdesk.php">Helpdesk</a></li> <li><a href="houses.php">Houses</a></li> <li><a href="deaths.php">Deaths</a></li> <li><a href="killers.php">Killers</a></li> E para adicionar Admin Helpdesk na sidebar do administrador edite /layout/widgets/Wadmin.php inserindo: <li> <a href='admin_helpdesk.php'>Admin Helpdesk</a> </li> Changelog: Citar 03/07/2014 - Código alterado para melhorar a segurança. Também fiz um pull request no github Abraços! Editado Junho 6, 2015 9 anos por Rhuan Gonzaga (veja o histórico de edições)
Postado Junho 30, 2014 10 anos Qualquer um posta e qualquer um pode responder ? Antica Global - Server Online SITE: http://anticaglobal.com/ IP: anticaglobal.com EXP: 999x [sTAGES] ML: 300x SKILL: 500x LOOT: 10x VERSÃO: 10.77 PORTA: 7171 Stages: 1 - 8 level, 999x 9 - 20 level, 950x 21 - 50 level, 800x 51 - 100 level, 750x 101 - 130 level, 650x 131 - 180 level, 550x 181 - 230 level, 450x 231 - 300 level, 350x 301+ level, 300x
Postado Junho 30, 2014 10 anos Acredito que para postar tem que ser qualquer um (com registro no site), agora para responder apenas o admin do site! # Regras Gerais - TibiaKing.com # Contato: augusto@tibiaking.comNão respondo dúvidas via MP.
Postado Julho 1, 2014 10 anos Autor Exato, somente usuários cadastrados podem abrir ticket e no ticket tem a interação do usuário que abriu o ticket e da staff. @Edit Acrescentei os comandos SQL que havia esquecido
Postado Julho 1, 2014 10 anos Bom se é assim, vou testar obrigado rep+ Antica Global - Server Online SITE: http://anticaglobal.com/ IP: anticaglobal.com EXP: 999x [sTAGES] ML: 300x SKILL: 500x LOOT: 10x VERSÃO: 10.77 PORTA: 7171 Stages: 1 - 8 level, 999x 9 - 20 level, 950x 21 - 50 level, 800x 51 - 100 level, 750x 101 - 130 level, 650x 131 - 180 level, 550x 181 - 230 level, 450x 231 - 300 level, 350x 301+ level, 300x
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.