<commit_before><?php
//this script may only be included - so its better to die if called directly.
if (strpos($_SERVER["SCRIPT_NAME"],basename(__FILE__)) !== false) {
  header("location: index.php");
  exit;
}

class CcLib extends UsersLib {

	var $db;
	var $date;
	var $msg = '';

	function CcLib($dbTiki) { 
		$this->db = $dbTiki;
		$this->date = date("U");
		$this->logfile = "mods/features/cc/cc.log.php";
		$this->initlog();
	}

	function initlog() {
		if (!is_file($this->logfile)) {
			$fp = fopen($this->logfile,'w');
			if ($fp) {
				fputs($fp,"<? header('Location: index.php'); die(); ?>\n");
				fclose($fp);
			}
		}
	}

	function tracklog($msg) {
		$fp = fopen($this->logfile,'a');
		fputs($fp,$msg."\n");
		fclose($fp);
	}

	function user_infos($user,$app=false) {
		$info = $this->get_user_info($user);
		$info['registered_cc'] = $this->get_registered_cc($user,$app);
		return $info;
	}

	function get_ledgers($offset=0,$max=-1,$sort_mode='last_tr_date_desc',$user=false,$cc=false,$app=false) {
		$query = 'select * from `cc_ledger`';
		$query_cant = 'select count(*) from `cc_ledger`';
		$bindvars = $mid = array();
		if ($user) {
			$mid[] = "`acct_id`=?";
			$bindvars[] = $user;
		}
		if ($cc) {
			$mid[] = "`cc_id`=?";
			$bindvars[] = $cc;
		}
		if ($approved) {
			$mid[] = "`approved`=?";
			$bindvars[] = $app;
		}
		if (count($mid)) {
			$mid = " where ". implode(' and ',$mid);
		} else {
			$mid = '';
		}
		$order = " order by ".$this->convert_sortmode($sort_mode);
		$result = $this->query($query.$mid.$order,$bindvars,$max,$offset);	
		$cant = $this->getOne($query_cant.$mid,$bindvars);
		$ret = array();<commit_msg>fixed buggy var<commit_after><?php
//this script may only be included - so its better to die if called directly.
if (strpos($_SERVER["SCRIPT_NAME"],basename(__FILE__)) !== false) {
  header("location: index.php");
  exit;
}

class CcLib extends UsersLib {

	var $db;
	var $date;
	var $msg = '';

	function CcLib($dbTiki) { 
		$this->db = $dbTiki;
		$this->date = date("U");
		$this->logfile = "mods/features/cc/cc.log.php";
		$this->initlog();
	}

	function initlog() {
		if (!is_file($this->logfile)) {
			$fp = fopen($this->logfile,'w');
			if ($fp) {
				fputs($fp,"<? header('Location: index.php'); die(); ?>\n");
				fclose($fp);
			}
		}
	}

	function tracklog($msg) {
		$fp = fopen($this->logfile,'a');
		fputs($fp,$msg."\n");
		fclose($fp);
	}

	function user_infos($user,$app=false) {
		$info = $this->get_user_info($user);
		$info['registered_cc'] = $this->get_registered_cc($user,$app);
		return $info;
	}

	function get_ledgers($offset=0,$max=-1,$sort_mode='last_tr_date_desc',$user=false,$cc=false,$app=false) {
		$query = 'select * from `cc_ledger`';
		$query_cant = 'select count(*) from `cc_ledger`';
		$bindvars = $mid = array();
		if ($user) {
			$mid[] = "`acct_id`=?";
			$bindvars[] = $user;
		}
		if ($cc) {
			$mid[] = "`cc_id`=?";
			$bindvars[] = $cc;
		}
		if ($app) {
			$mid[] = "`approved`=?";
			$bindvars[] = $app;
		}
		if (count($mid)) {
			$mid = " where ". implode(' and ',$mid);
		} else {
			$mid = '';
		}
		$order = " order by ".$this->convert_sortmode($sort_mode);
		$result = $this->query($query.$mid.$order,$bindvars,$max,$offset);	
		$cant = $this->getOne($query_cant.$mid,$bindvars);
		$ret = array();
{'fraction_non_alphanumeric': 0.23747342848466443, 'fraction_numerical': 0.0012146978439113271, 'mean_word_length': 3.9683257918552037, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 29, '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': '4529988', 'n_tokens_mistral': 1463, 'n_tokens_neox': 1323, 'n_words': 239}