<commit_before><?php
// TODO doc

class user
{
	public $id;
	public $name;
	public $level;
	public $nick;
	public $ident;
	public $host;
	public $title;
	public $location;
	public $tv_channels = "'prosieben.de','rtl.de','sat1.de'";

	public function __construct($nick, $ident, $host)
	{
		global $db;

		$this->nick = $nick;
		$this->ident = $ident;
		$this->host = $host;

		$user = $db->query('SELECT *
				    FROM `users`
				    WHERE `id`=(SELECT `usrid`
						FROM `hosts`
						WHERE ' . $db->quote($ident) . ' LIKE `ident` AND
						' . $db->quote($host) . ' LIKE `host` LIMIT 1) LIMIT 1')->fetchObject();
		if (!$user)
			return false;
		$this->id = $user->id;
		$this->level = $user->ulvl;
		$this->name = $user->username;
		$this->title = $user->title;
		$userdata = unserialize($user->userdata);
		if (isset ($userdata['location']))
			$this->location = $userdata['location'];
		if (isset ($userdata['tv_channels']))
			$this->tv_channels = $userdata['tv_channels'];
	}

	function update_userdata($key, $value)
	{
		global $db;

		if ($this->$key == $value)
			return;
		$userdata[$key] = $value;
		$this->$key = $value;
		$db->query('UPDATE `users` SET `userdata`=' . $db->quote(serialize($userdata)) . ' WHERE `id`=' . (int)$this->id);
	}
}

?><commit_msg>user: Documentation<commit_after><?php
/**
 * user management
 *
 * @author <NAME> <<EMAIL>>
 * @package foobot
 **/

/**
 * user management
 * @package foobot
 * @subpackage classes
 **/
class user
{
	/**
	 * Userid
	 * @var int
	 **/
	public $id;

	/**
	 * Username
	 * @var string
	 **/
	public $name;

	/**
	 * Userlevel
	 * @var int
	 **/
	public $level;

	/**
	 * Current nickname
	 * @var string
	 **/
	public $nick;

	/**
	 * Current ident
	 * @var string
	 **/
	public $ident;

	/**
	 * Current hostname
	 * @var string
	 **/
	public $host;

	/**
	 * Title
	 * @var string
	 **/
	public $title;

	/**
	 * Location (TODO move to google plugin)
	 * @var string
	 **/
	public $location;

	/**
	 * Personal TV channel list (TODO move to tv plugin)
	 * @var string
	 **/
	public $tv_channels = "'prosieben.de','rtl.de','sat1.de'";

	/**
	 * Class constructor
	 * @param string $nick Current nick
	 * @param string $ident Current ident
	 * @param string $host Current hostname
	 **/
	public function __construct($nick, $ident, $host)
	{
		global $db;

		$this->nick = $nick;
		$this->ident = $ident;
		$this->host = $host;

		$user = $db->query('SELECT *
				    FROM `users`
				    WHERE `id`=(SELECT `usrid`
						FROM `hosts`
						WHERE ' . $db->quote($ident) . ' LIKE `ident` AND
						' . $db->quote($host) . ' LIKE `host` LIMIT 1) LIMIT 1')->fetchObject();
		if (!$user)
			return false;
		$this->id = $user->id;
		$this->level = $user->ulvl;
		$this->name = $user->username;
		$this->title = $user->title;
		$userdata = unserialize($user->userdata);
		if (isset ($userdata['location']))
			$this->location = $userdata['location'];
		if (isset ($userdata['tv_channels']))
			$this->tv_channels = $userdata['tv_channels'];
	}

	/**
	 * Change userdata
	 * @param string $key
	 * @param string $value
	 **/
	function update_userdata($key, $value)
	{
		global $db;

		if ($this->$key == $value)
			return;
		$userdata[$key] = $value;
		$this->$key = $value;
		$db->query('UPDATE `users` SET `userdata`=' . $db->quote(serialize($userdata)) . ' WHERE `id`=' . (int)$this->id);
	}
}

?>
{'fraction_non_alphanumeric': 0.20404521118381916, 'fraction_numerical': 0.001784651992861392, 'mean_word_length': 3.1213235294117645, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 54, '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': '5865022', 'n_tokens_mistral': 1375, 'n_tokens_neox': 1213, 'n_words': 286}