<commit_before><?php

// bzflsMy.php
//
// Copyright (c) 1993 - 2003 <NAME>
//
// This package is free software;  you can redistribute it and/or
// modify it under the terms of the license found in the file
// named COPYING that should have accompanied this file.
//
// THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
// WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.

$dbhost  = "localhost";
$dbuname = "bzflag";
$dbpass  = "";
$dbname  = "bzflag";

# Common to all
$action   = $_GET['action'];
$nameport = $_GET['nameport'];

# For ADD
$build    = $_GET['build'];
$version  = $_GET['version'];
$gameinfo = $_GET['gameinfo'];
$title    = $_GET['title'];

# Connect to the server database.
$link = mysql_connect($dbhost, $dbuname, $dbpass)
     or die("Could not connect: " . mysql_error());
if (!mysql_select_db($dbname)) {
  mysql_create_db($dbname) or die("Could not create db: " . mysql_error());
}
$result = mysql_query("SELECT * FROM servers");

# If the servers table does not exist, create it.
if (!$result) {
  mysql_query("CREATE TABLE servers " .
	      "(nameport varchar(60) NOT NULL, " .
	      " build varchar(20), " .
	      " version varchar(9) NOT NULL, " .
	      " gameinfo varchar(73) NOT NULL, " .
	      " ipaddr varchar(17) NOT NULL, " .
	      " title varchar(80), " .
	      " lastmod INT NOT NULL DEFAULT '0', ".
	      " PRIMARY KEY (nameport))")
    or die ("Could not create table: " . mysql_error());
}
# remove all inactive servers from the table
$timeout = 1800;    # timeout in seconds
$staletime = time() - $timeout;
mysql_query("DELETE FROM servers WHERE lastmod < $staletime")
     or die("Could not drop old items" . mysql_error());

header("Content-type: text/plain");
# Do stuff based on what the 'action' is...
#
#  -- LIST --
# Same as LIST in the old bzfls
if (!array_key_exists("action", $_GET) || $action == "LIST" ) {
  if ($version)
    $result = mysql_query("SELECT nameport,version,gameinfo,ipaddr,title "
			  . " FROM servers WHERE version = '$version'")
      or die ("Invalid query: ". mysql_error());
  else
    $result = mysql_query("SELECT nameport,version,gameinfo,ipaddr,title "
			  . " FROM servers")
      or die ("Invalid query: ". mysql_error());
  while (TRUE) {
    $row = mysql_fetch_row($result);
    if (!$row)
      break;
    $line = implode(" ", $row);
    print "$line\n";<commit_msg>minor speed improvement<commit_after><?php

// bzflsMy.php
//
// Copyright (c) 1993 - 2003 <NAME>
//
// This package is free software;  you can redistribute it and/or
// modify it under the terms of the license found in the file
// named COPYING that should have accompanied this file.
//
// THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
// WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.

$dbhost  = "localhost";
$dbuname = "bzflag";
$dbpass  = "";
$dbname  = "bzflag";

# Common to all
$action   = $_GET['action'];
$nameport = $_GET['nameport'];

# For ADD
$build    = $_GET['build'];
$version  = $_GET['version'];
$gameinfo = $_GET['gameinfo'];
$title    = $_GET['title'];

# Connect to the server database.
$link = mysql_connect($dbhost, $dbuname, $dbpass)
     or die("Could not connect: " . mysql_error());
if (!mysql_select_db($dbname)) {
  mysql_create_db($dbname) or die("Could not create db: " . mysql_error());
}

# If the servers table does not exist, create it.
$result = mysql_query("SELECT 1 FROM servers");
if (!$result) {
  mysql_query("CREATE TABLE servers " .
	      "(nameport varchar(60) NOT NULL, " .
	      " build varchar(20), " .
	      " version varchar(9) NOT NULL, " .
	      " gameinfo varchar(73) NOT NULL, " .
	      " ipaddr varchar(17) NOT NULL, " .
	      " title varchar(80), " .
	      " lastmod INT NOT NULL DEFAULT '0', ".
	      " PRIMARY KEY (nameport))")
    or die ("Could not create table: " . mysql_error());
}

# remove all inactive servers from the table
$timeout = 1800;    # timeout in seconds
$staletime = time() - $timeout;
mysql_query("DELETE FROM servers WHERE lastmod < $staletime")
     or die("Could not drop old items" . mysql_error());

header("Content-type: text/plain");
# Do stuff based on what the 'action' is...
#
#  -- LIST --
# Same as LIST in the old bzfls
if (!array_key_exists("action", $_GET) || $action == "LIST" ) {
  if ($version)
    $result = mysql_query("SELECT nameport,version,gameinfo,ipaddr,title "
			  . " FROM servers WHERE version = '$version'")
      or die ("Invalid query: ". mysql_error());
  else
    $result = mysql_query("SELECT nameport,version,gameinfo,ipaddr,title "
			  . " FROM servers")
      or die ("Invalid query: ". mysql_error());
  while (TRUE) {
    $row = mysql_fetch_row($result);
    if (!$row)
      break;
    $line = implode(" ", $row);
    print "$line\n";
{'fraction_non_alphanumeric': 0.15248730964467005, 'fraction_numerical': 0.009949238578680204, 'mean_word_length': 3.390374331550802, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '459135', 'n_tokens_mistral': 1618, 'n_tokens_neox': 1539, 'n_words': 510}