<commit_before><?php

/**
* c4_file Class
* Class used to deal with files information that is storaged in DB
* It's used in the BO in the files plugin and module
* Can also be used to deal with files for front-end purposes.
*
* @author 	<NAME>
* @version 1.1
* @since 2016-10
* @license The MIT License (MIT)
*/

class c4_file {
	protected $id; /** @var int **/
	protected $file; /** @var string **/
	protected $type; /** @var string **/
	protected $module; /** @var string **/
	protected $id_ass; /** @var int **/
	protected $description; /** @var string **/
	protected $code; /** @var string **/
	protected $sort = 0; /** @var int **/
	protected $user_id; /** @var int **/

	public function __construct() {}

	/** === SET METHODS === **/

	/** @param int **/
	public function setId ($i) {$this->id = $i;}

	/** @param string **/
	public function setFile ($f) {$this->file = $f;}

	/** @param string **/
	public function setType ($t) {
		switch ($t) {
			case 'img':
				$this->type = "img";
				break;
			case 'doc':
				$this->type = "doc";
				break;
			default:
				$this->type = "img";
				break;
		}
	}

	/** @param string **/
	public function setModule ($m) {$this->module = $m;}

	/** @param string **/
	public function setDescription ($d) {$this->description = $d;}

	/** @param string **/
	public function setCode ($c) {$this->code = $c;}

	/** @param int **/
	public function setIdAss ($ia) {$this->id_ass = $ia;}

	/** @param int **/
	public function setSort ($s) {$this->sort = $s;}

	/** @param int **/
	public function setUserId ($u) {$this->user_id = $u;}

	/** [Insert new file regist in DB] @return boolean */
	public function insert () {
		global $cfg, $db;

		return $db->query(sprintf(
			"INSERT INTO %s_4_files (file, type, module, id_ass, description, code, sort, user_id) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",
			$cfg->db->prefix,
			$this->file,
			$this->type,
			$this->module,
			$this->id_ass,
			'',
			'',
			$this->user_id,
			$db->real_escape_string($this->sort)
		));
	}

	/** [Update file regist in DB by given ID] @return boolean */
	public function update () {
		global $cfg, $db;
<commit_msg>update files class<commit_after><?php

/**
* c4_file Class
* Class used to deal with files information that is storaged in DB
* It's used in the BO in the files plugin and module
* Can also be used to deal with files for front-end purposes.
*
* @author 	<NAME>
* @version 1.1
* @since 2016-10
* @license The MIT License (MIT)
*/

class c4_file {
	protected $id; /** @var int **/
	protected $file; /** @var string **/
	protected $type; /** @var string **/
	protected $module; /** @var string **/
	protected $id_ass; /** @var int **/
	protected $description; /** @var string **/
	protected $code; /** @var string **/
	protected $sort = 0; /** @var int **/
	protected $user_id; /** @var int **/

	public function __construct() {}

	/** === SET METHODS === **/

	/** @param int **/
	public function setId ($i) {$this->id = $i;}

	/** @param string **/
	public function setFile ($f) {$this->file = $f;}

	/** @param string **/
	public function setType ($t) {
		switch ($t) {
			case 'img':
				$this->type = "img";
				break;
			case 'doc':
				$this->type = "doc";
				break;
			default:
				$this->type = "img";
				break;
		}
	}

	/** @param string **/
	public function setModule ($m) {$this->module = $m;}

	/** @param string **/
	public function setDescription ($d) {$this->description = $d;}

	/** @param string **/
	public function setCode ($c) {$this->code = $c;}

	/** @param int **/
	public function setIdAss ($ia) {$this->id_ass = $ia;}

	/** @param int **/
	public function setSort ($s) {$this->sort = $s;}

	/** @param int **/
	public function setUserId ($u) {$this->user_id = $u;}

	/** [Insert new file regist in DB] @return boolean */
	public function insert () {
		global $cfg, $db;

		$to_return = $db->query(sprintf(
			"INSERT INTO %s_4_files (file, type, module, id_ass, description, code, sort, user_id) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",
			$cfg->db->prefix,
			$this->file,
			$this->type,
			$this->module,
			$this->id_ass,
			'',
			'',
			$this->user_id,
			$db->real_escape_string($this->sort)
		));

		$this->id = $db->insert_id;

		return $to_return;
	}

	/** [Update file regist in DB by given ID] @return boolean */
	public function update () {
		global $cfg, $db;

{'fraction_non_alphanumeric': 0.2078754578754579, 'fraction_numerical': 0.005494505494505495, 'mean_word_length': 3.180861244019139, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 49, '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': '3203333', 'n_tokens_mistral': 1681, 'n_tokens_neox': 1524, 'n_words': 480}