<commit_before><?php
/**
 * bofh plugin
 *
 * @author <NAME> <<EMAIL>>
 * @package foobot
 */

/**
 * Implementation of plugin_interface
 * @package foobot
 * @subpackage plugins
 */
class bofh extends plugin_interface
{
	public function init()
	{
		$this->register_event('command', 'bofh', 'pub_bofh');
		$this->register_event('command', 'addlart');
		$this->register_event('command', 'lart');

		$this->register_help('bofh', 'BOFH excuses');
		$this->register_help('addlart', 'add a LART');
		$this->register_help('lart', 'LART someone');

		db::get_instance()->query('CREATE TABLE IF NOT EXISTS larts (lart varchar(50))');
	}

	public function pub_bofh($args)
	{
		$excuse = exec('/usr/bin/fortune bofh-excuses');
		parent::answer($excuse);
	}

	public function addlart($args)
	{
		$db = db::get_instance();

		$lart = implode(' ', $args);
		$db->query('INSERT INTO `larts` VALUES(' . $db->quote($lart) . ')');
		parent::answer('Added LART');
	}

	public function lart($args)
	{
		$bot = bot::get_instance();
		$db = db::get_instance();
		$channel = $bot->channel;
		$usr = $bot->usr;

		if (empty ($args))
			$nick = $usr->nick;
		else
			$nick = $args[0];

		$lart = $db->get_single_property('SELECT `lart` FROM `larts` ORDER BY RANDOM() LIMIT 1');
		$bot->act($channel, 'slaps ' . $nick . ' with ' . $lart);
	}
}
<commit_msg>bofh: Use prepated statements<commit_after><?php
/**
 * bofh plugin
 *
 * @author <NAME> <<EMAIL>>
 * @package foobot
 */

/**
 * Implementation of plugin_interface
 * @package foobot
 * @subpackage plugins
 */
class bofh extends plugin_interface
{
	public function init()
	{
		$this->register_event('command', 'bofh', 'pub_bofh');
		$this->register_event('command', 'addlart');
		$this->register_event('command', 'lart');

		$this->register_help('bofh', 'BOFH excuses');
		$this->register_help('addlart', 'add a LART');
		$this->register_help('lart', 'LART someone');

		db::get_instance()->query('CREATE TABLE IF NOT EXISTS larts (lart varchar(50))');
	}

	public function pub_bofh($args)
	{
		$excuse = exec('/usr/bin/fortune bofh-excuses');
		parent::answer($excuse);
	}

	public function addlart($args)
	{
		$db = db::get_instance();

		$lart = implode(' ', $args);
		$db->query('INSERT INTO `larts` VALUES(?)', $lart);
		parent::answer('Added LART');
	}

	public function lart($args)
	{
		$bot = bot::get_instance();
		$db = db::get_instance();
		$channel = $bot->channel;
		$usr = $bot->usr;

		if (empty ($args))
			$nick = $usr->nick;
		else
			$nick = $args[0];

		$lart = $db->get_single_property('SELECT `lart` FROM `larts` ORDER BY RANDOM() LIMIT 1');
		$bot->act($channel, 'slaps ' . $nick . ' with ' . $lart);
	}
}

{'fraction_non_alphanumeric': 0.20443442314919202, 'fraction_numerical': 0.003006388575723412, 'mean_word_length': 4.366935483870968, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 36, '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': '5583968', 'n_tokens_mistral': 1080, 'n_tokens_neox': 997, 'n_words': 209}