<commit_before><?php

/**
 *
 */

function generate_transid()
{
	global $base_url, $s_id;
	return substr(sha1($s_id .microtime()), 0, 12) . '_' . $s_id . '@' . $base_url;
}

/*
 *
 */

function sign_transaction($transaction, $sharedsecret)
{
	$amount = (float) $transaction['amount'];
	$amount = $amount * 100;
	$amount = round($amount);
	$tosign = $sharedsecret . $transaction['transid'] . strtolower($transaction['letscode_to']) . $amount;
	$signature = sha1($tosign);
	log_event('debug','Signing ' . $tosign . ' : ' . $signature);
	return $signature;
}

/*
 *
 */

function insert_transaction($transaction)
{
    global $app, $s_id, $currency, $s_master;

	$transaction['creator'] = ($s_master) ? 0 : (($s_id) ? $s_id : 0);
    $transaction['cdate'] = date('Y-m-d H:i:s');

	$app['db']->beginTransaction();

	try
	{
		$app['db']->insert('transactions', $transaction);
		$id = $app['db']->lastInsertId('transactions_id_seq');
		$app['db']->executeUpdate('update users set saldo = saldo + ? where id = ?', [$transaction['amount'], $transaction['id_to']]);
		$app['db']->executeUpdate('update users set saldo = saldo - ? where id = ?', [$transaction['amount'], $transaction['id_from']]);
		$app['db']->commit();

	}
	catch(Exception $e)
	{
		$app['db']->rollback();
		throw $e;
		return false;
	}<commit_msg>transactions cdate gmt<commit_after><?php

/**
 *
 */

function generate_transid()
{
	global $base_url, $s_id;
	return substr(sha1($s_id .microtime()), 0, 12) . '_' . $s_id . '@' . $base_url;
}

/*
 *
 */

function sign_transaction($transaction, $sharedsecret)
{
	$amount = (float) $transaction['amount'];
	$amount = $amount * 100;
	$amount = round($amount);
	$tosign = $sharedsecret . $transaction['transid'] . strtolower($transaction['letscode_to']) . $amount;
	$signature = sha1($tosign);
	log_event('debug','Signing ' . $tosign . ' : ' . $signature);
	return $signature;
}

/*
 *
 */

function insert_transaction($transaction)
{
    global $app, $s_id, $currency, $s_master;

	$transaction['creator'] = ($s_master) ? 0 : (($s_id) ? $s_id : 0);
    $transaction['cdate'] = gmdate('Y-m-d H:i:s');

	$app['db']->beginTransaction();

	try
	{
		$app['db']->insert('transactions', $transaction);
		$id = $app['db']->lastInsertId('transactions_id_seq');
		$app['db']->executeUpdate('update users set saldo = saldo + ? where id = ?', [$transaction['amount'], $transaction['id_to']]);
		$app['db']->executeUpdate('update users set saldo = saldo - ? where id = ?', [$transaction['amount'], $transaction['id_from']]);
		$app['db']->commit();

	}
	catch(Exception $e)
	{
		$app['db']->rollback();
		throw $e;
		return false;
	}
{'fraction_non_alphanumeric': 0.22839741149600304, 'fraction_numerical': 0.007613247049866768, 'mean_word_length': 4.827050997782705, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, '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': '6485570', 'n_tokens_mistral': 1010, 'n_tokens_neox': 970, 'n_words': 170}