thankyou
Donate to the B3 fund!

"even a small donation helps!"
Donate with PayPal!
Echelon v2 is not yet officially released! If you cannot get this dev-version installed, revert to version 1 as available in our download section.

Author Topic: [SOLVED] Talkback to record to the chatlog  (Read 1652 times)

Offline Kellithe

  • Jr. Member
  • **
  • Posts: 34
    • RoC
[SOLVED] Talkback to record to the chatlog
« on: November 02, 2013, 12:41:49 AM »
I'm trying to get the talkback function to add entires into the chatlog database. Anyone know why the following isn't working? This is in the chats.php file at line 19.

Code: [Select]
$talkback = "";
if (isset($_POST['talkback'])) {
  $talkback = $_POST['talkback'];
  if ($talkback != "") {
    $command = "say ^4[B3](^3" . $_SESSION['xlradmin'] . "^4): ^3" . $talkback;
    //echo "command: " . $command;
    rcon ($command);
$cname = "^4[B3](^3" . $_SESSION['xlradmin'];
$sql = "INSERT IGNORE INTO `chatlog` (`id`, `msg_time`, `msg_type`, `client_id`, `client_name`, `client_team`, `msg`, `target_id`, `target_name`, `target_team`) VALUES ('', UNIX_TIMESTAMP(), 'ALL', '1', '". $cname ."', '3', '". $talkback ."', NULL, NULL, NULL)";
mysql_select_db($database_b3connect, $b3connect);
mysql_query($sql, $b3connect);
  }
}

I think it is something with my variables in the $sql = line.
I also tried the following, which didn't work either:

Code: [Select]
$sql = "INSERT IGNORE INTO `chatlog` (`id`, `msg_time`, `msg_type`, `client_id`, `client_name`, `client_team`, `msg`, `target_id`, `target_name`, `target_team`) VALUES ('', UNIX_TIMESTAMP(), 'ALL', '1', '$cname', '3', '$talkback', NULL, NULL, NULL)"; 

If I go into phpMyAdmin and put the code in, and just replace the $variables with actual data it works. So it's something with my $variables I assume. Syntax issue or something.

Any idea?
« Last Edit: November 02, 2013, 11:47:31 PM by Kellithe »

Offline 82ndAB.Bravo17

  • Dev. Team
  • Hero Member
  • *
  • Posts: 2628
Re: Trying to get talkback to record to the chatlog DB
« Reply #1 on: November 02, 2013, 05:06:37 AM »
What error does it give?

Offline Kellithe

  • Jr. Member
  • **
  • Posts: 34
    • RoC
Re: Trying to get talkback to record to the chatlog DB
« Reply #2 on: November 02, 2013, 11:46:59 PM »
I figured it out, I was in the WRONG file completely. I found the talkback() function in ajax.php and editted it.

Code: [Select]
function talkback() {
  $game = getPostOrGet('game');
  if (is_null($game)) {
    header("HTTP/1.1 400 Bad Request");
    echo "game undefined";
    exit();
  }
  
  global $config;
  //echo print_r($config["servers"][$game], true); exit;
  loadGameConfig($config["servers"][$game]);

  global $rcon_ip, $rcon_port, $rcon_pass;
  //echo "$rcon_ip, $rcon_port, $rcon_pass"; exit;
  
  $talkback = getPostOrGet('talkback');
  if (is_null($talkback)) {
    header("HTTP/1.1 400 Bad Request");
    echo "talkback undefined";
    exit();
  }
  
  if ("".$talkback != "") {
    require_once('admin/rcon.php');
    require_once('Connections/b3connect.php');
    require_once('login/inc_authorize.php');
    global $database_b3connect, $b3connect;
    
    $command = "say ^4[B3](^3" . $_SESSION['xlradmin'] . "^4): ^3" . $talkback;
    //echo "command: " . $command;
    header('Content-type: text/plain');
    echo rcon($command)."\n";

    $cname = "[Echelon] (" . $_SESSION['xlradmin'] . ")";
    $sql = "INSERT IGNORE INTO `chatlog` (`id`, `msg_time`, `msg_type`, `client_id`, `client_name`, `client_team`, `msg`, `target_id`, `target_name`, `target_team`) VALUES ('', UNIX_TIMESTAMP(), 'ALL', '1', '$cname', '3', '$talkback', NULL, NULL, NULL)";
    mysql_select_db($database_b3connect, $b3connect);
    mysql_query($sql, $b3connect);
  } else {
    header("HTTP/1.1 400 Bad Request");
    echo "talkback message is empty";
    exit();
  }
}

It works. Now, when someone uses talkback, it will log it in the chatlog table. It will show up as [Echelon] (Echelon login name) message

P.S. The "search all files" ability of notepad++ comes in very handy...
« Last Edit: November 02, 2013, 11:52:08 PM by Kellithe »

 


Rate this page +1 at Google Search

anything