--- /dev/null
+<?php
+$db['host'] = "localhost";
+$db['user'] = "neonserv";
+$db['pass'] = "";
+$db['base'] = "neonserv";
+
+$db['conn'] = @mysql_connect($db['host'], $db['user'], $db['pass']) or die(mysql_error());
+if($db['conn']) {
+ $mysql_connection=TRUE;
+ mysql_select_db($db['base'], $db['conn']) OR $mysql_connection=FALSE;
+}
+
+if(!$mysql_connection)
+ die("no connection to the MySQL Server.");
+
+$id = $_GET['id'];
+$key = $_GET['key'];
+if(!is_numeric($id) || strlen($key) != 32)
+ die("Access denied");
+
+$result = mysql_query("SELECT `nick`, `hand`, `host`, `time`, `status`, `text`, `log`, `supporter`, `users`.`user_user`, MD5(CONCAT(`id`, `host`, `time`, `supporter`)) FROM `helpserv_requests` LEFT JOIN `users` ON `supporter` = `user_id` WHERE `id` = '".mysql_real_escape_string($id)."';");
+if(mysql_num_rows($result) == 0)
+ die("Access denied");
+$row = mysql_fetch_row($result);
+if(strtolower($row[9]) != strtolower($key))
+ die("Access denied");
+
+?>
+<table border="1" width="600">
+ <tr>
+ <td width="150">Nick:</td>
+ <td><?php echo$row[0]; ?></td>
+ </tr>
+ <tr>
+ <td width="150">Hostmask:</td>
+ <td><?php echo$row[2]; ?> (auth: <?php echo$row[1]; ?>)</td>
+ </tr>
+ <tr>
+ <td width="150">Time</td>
+ <td><?php echo date("d.m.Y H:i:s", $row[3]); ?></td>
+ </tr>
+ <tr>
+ <td width="150">State</td>
+ <td>
+ <?php
+ if($row[4] == 0)
+ echo"pending";
+ else if($row[4] == 1)
+ echo "active (".$row[8].")";
+ else if($row[4] == 2)
+ echo "closed (".($row[7] == 0 ? "*" : $row[8]).")";
+ ?>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2"><span style="font-size:10pt; font-family:Courier New;"><?php echo str_replace("\n", "<br>", $row[5]); ?></span></td>
+ </tr>
+ <tr>
+ <td colspan="2"><span style="font-size:10pt; font-family:Courier New;"><?php echo str_replace("\n", "<br>", $row[6]); ?></span></td>
+ </tr>
+</table>
\ No newline at end of file
{"NH_REQUESTS_HEADER_STATUS", "State"},
{"NH_REQUESTS_HEADER_NICK", "Nick"},
{"NH_REQUESTS_HEADER_TIME", "Time"},
+ {"NH_REQUESTS_HEADER_STATUS", "State"},
+ {"NH_REQUESTS_HEADER_AUTH", "Auth"},
+ {"NH_REQUESTS_HEADER_MASK", "Mask"},
{"NH_REQUESTS_HEADER_REQUEST", "Question"},
{"NH_REQUESTS_STATE_ACTIVE", "active"},
{"NH_REQUESTS_STATE_PENDING", "pending"},
+ {"NH_REQUESTS_STATE_CLOSED", "closed"},
{"NH_REQUESTS_STATE_ERROR", "ERROR"},
{"NH_STATS_HEADER_USER", "User"},
{"NH_STATS_HEADER_LAST_24H", "last 24h"},
--- /dev/null
+/* cmd_neonhelp_history.c - NeonServ v5.4
+ * Copyright (C) 2011-2012 Philipp Kreil (pk910)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "cmd_neonhelp.h"
+
+/*
+* argv[0] matching string
+*/
+
+CMD_BIND(neonhelp_cmd_history) {
+ //check permissions
+ MYSQL_RES *res;
+ MYSQL_ROW row, row2;
+ int caccess = 0;
+ int userid;
+ printf_mysql_query("SELECT `helpserv_support`, `helpserv_public`, `helpserv_intern` FROM `helpserv_settings` WHERE `helpserv_botid` = '%d'", client->clientid);
+ res = mysql_use();
+ if (!(row = mysql_fetch_row(res))) return;
+ //check if the user is a supporter (access in the support channel)
+ if((user->flags & USERFLAG_ISAUTHED)) {
+ if(user->flags & USERFLAG_HAS_USERID)
+ userid = user->user_id;
+ else {
+ printf_mysql_query("SELECT `user_id` FROM `users` WHERE `user_user` = '%s'", escape_string(user->auth));
+ res = mysql_use();
+ if ((row2 = mysql_fetch_row(res)) != NULL) {
+ userid = atoi(row2[0]);
+ user->user_id = userid;
+ user->flags |= USERFLAG_HAS_USERID;
+ } else
+ userid = 0;
+ }
+ printf_mysql_query("SELECT `chanuser_access`, `chanuser_flags` FROM `chanusers` LEFT JOIN `channels` ON `chanuser_cid` = `channel_id` WHERE `chanuser_uid` = '%d' AND `channel_name` = '%s'", userid, escape_string(row[0]));
+ res = mysql_use();
+ if ((row2 = mysql_fetch_row(res)) != NULL) {
+ int cflags = atoi(row2[1]);
+ if(!(cflags & DB_CHANUSER_SUSPENDED))
+ caccess = atoi(row2[0]);
+ }
+ }
+ if(!caccess) {
+ reply(textclient, user, "MODCMD_ACCESS_DENIED");
+ return;
+ }
+ struct Table *table;
+ char *match_str = escape_string(argv[0]);
+ printf_mysql_query("SELECT `id`, `nick`, `hand`, `host`, `time`, `text`, `status`, `supporter`, `users`.`user_user`, MD5(CONCAT(`id`, `host`, `time`, `supporter`)) FROM `helpserv_requests` LEFT JOIN `users` ON `supporter` = `user_id` WHERE `botid` = '%d' AND (`host` LIKE '%%%s%%' OR `hand` LIKE '%%%s%%' OR `nick` LIKE '%%%s%%') ORDER BY `time` ASC", client->clientid, match_str, match_str, match_str);
+ res = mysql_use();
+ table = table_init(6, mysql_num_rows(res)*3 + 1, 0);
+ table->col_flags[1] |= TABLE_FLAG_COL_SKIP_NULL;
+ table->col_flags[2] |= TABLE_FLAG_COL_SKIP_NULL;
+ table->col_flags[3] |= TABLE_FLAG_COL_SKIP_NULL;
+ table->col_flags[4] |= TABLE_FLAG_COL_SKIP_NULL;
+ char *content[6];
+ content[0] = get_language_string(user, "NH_REQUESTS_HEADER_ID");
+ content[1] = get_language_string(user, "NH_REQUESTS_HEADER_NICK");
+ content[2] = get_language_string(user, "NH_REQUESTS_HEADER_AUTH");
+ content[3] = get_language_string(user, "NH_REQUESTS_HEADER_MASK");
+ content[4] = get_language_string(user, "NH_REQUESTS_HEADER_TIME");
+ content[5] = get_language_string(user, "NH_REQUESTS_HEADER_STATUS");
+ table_add(table, content);
+ char timestr[MAXLEN];
+ time_t rawtime;
+ struct tm *timeinfo;
+ char statestr[MAXLEN];
+ while ((row = mysql_fetch_row(res)) != NULL) {
+ content[0] = row[0];
+ content[1] = row[1];
+ content[2] = row[2];
+ content[3] = row[3];
+ rawtime = atoi(row[4]);
+ timeinfo = localtime(&rawtime);
+ strftime(timestr, MAXLEN, "%d.%m.%Y %H:%M:%S", timeinfo);
+ content[4] = timestr;
+ switch(atoi(row[6])) {
+ case 0:
+ content[5] = get_language_string(user, "NH_REQUESTS_STATE_PENDING");
+ break;
+ case 1:
+ sprintf(statestr, "%s (%s)", get_language_string(user, "NH_REQUESTS_STATE_ACTIVE"), row[8]);
+ content[5] = statestr;
+ break;
+ case 2:
+ sprintf(statestr, "%s (%s)", get_language_string(user, "NH_REQUESTS_STATE_CLOSED"), (strcmp(row[7], "0") ? row[8] : "*"));
+ content[5] = statestr;
+ break;
+ }
+ table_add(table, content);
+ char *p;
+ if((p = strstr(row[5], "\n")))
+ *p = '\0';
+ content[0] = " ";
+ content[1] = NULL;
+ content[2] = NULL;
+ content[3] = NULL;
+ content[4] = NULL;
+ sprintf(statestr, "\00314\002\002%s\003", row[5]);
+ content[5] = statestr;
+ table_add(table, content);
+ char setting[128];
+ sprintf(setting, "modules.%s.log_link", get_module_name(module_id));
+ if((p = get_string_field(setting))) {
+ statestr[0] = '\003';
+ statestr[1] = '1';
+ statestr[2] = '4';
+ int pos = sprintf(statestr+3, p, row[0], row[9]);
+ statestr[pos+3] = '\003';
+ statestr[pos+4] = '\0';
+ content[5] = statestr;
+ table_add(table, content);
+ }
+ }
+ //send the table
+ char **table_lines = table_end(table);
+ int i;
+ for(i = 0; i < table->entrys; i++) {
+ reply(textclient, user, table_lines[i]);
+ }
+ if(table->entrys == 1)
+ reply(textclient, user, "NS_TABLE_NONE");
+ table_free(table);
+}