<commit_before><?php
/**
 * @file mod/friendica.php
 */

use Friendica\App;
use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\Hook;
use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Module\Register;

function friendica_init(App $a)
{
	if (!empty($a->argv[1]) && ($a->argv[1] == "json")) {
		$register_policies = [
			Register::CLOSED  => 'REGISTER_CLOSED',
			Register::APPROVE => 'REGISTER_APPROVE',
			Register::OPEN    => 'REGISTER_OPEN'
		];

		$register_policy_int = intval(Config::get('config', 'register_policy'));
		if ($register_policy_int !== Register::CLOSED && Config::get('config', 'invitation_only')) {
			$register_policy = 'REGISTER_INVITATION';
		} else {
			$register_policy = $register_policies[$register_policy_int];
		}

		$sql_extra = '';
		if (Config::get('config', 'admin_nickname') !== null) {
			$sql_extra = sprintf(" AND `nickname` = '%s' ", DBA::escape(Config::get('config', 'admin_nickname')));
		}
		if (!empty(Config::get('config', 'admin_email'))) {
			$adminlist = explode(",", str_replace(" ", "", Config::get('config', 'admin_email')));

			$r = q("SELECT `username`, `nickname` FROM `user` WHERE `email` = '%s' $sql_extra", DBA::escape($adminlist[0]));
			$admin = [
				'name' => $r[0]['username'],
				'profile'=> System::baseUrl() . '/profile/' . $r[0]['nickname'],
			];
		} else {
			$admin = false;
		}

		$visible_addons = Addon::getVisibleList();

		Config::load('feature_lock');
		$locked_features = [];
		$featureLock = Config::get('config', 'feature_lock');
		if (isset($featureLock)) {
			foreach ($featureLock as $k => $v) {
				if ($k === 'config_loaded') {
					continue;
				}

				$locked_features[$k] = intval($v);
			}
		}
<commit_msg>Fix for possible notice "Undefined offset: 0"<commit_after><?php
/**
 * @file mod/friendica.php
 */

use Friendica\App;
use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\Hook;
use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Module\Register;

function friendica_init(App $a)
{
	if (!empty($a->argv[1]) && ($a->argv[1] == "json")) {
		$register_policies = [
			Register::CLOSED  => 'REGISTER_CLOSED',
			Register::APPROVE => 'REGISTER_APPROVE',
			Register::OPEN    => 'REGISTER_OPEN'
		];

		$register_policy_int = intval(Config::get('config', 'register_policy'));
		if ($register_policy_int !== Register::CLOSED && Config::get('config', 'invitation_only')) {
			$register_policy = 'REGISTER_INVITATION';
		} else {
			$register_policy = $register_policies[$register_policy_int];
		}

		$condition = [];
		$admin = false;
		if (!empty(Config::get('config', 'admin_nickname'))) {
			$condition['nickname'] = Config::get('config', 'admin_nickname');
		}
		if (!empty(Config::get('config', 'admin_email'))) {
			$adminlist = explode(",", str_replace(" ", "", Config::get('config', 'admin_email')));
			$condition['email'] = $adminlist[0];
			$administrator = DBA::selectFirst('user', ['username', 'nickname'], $condition);
			if (DBA::isResult($administrator)) {
				$admin = [
					'name' => $administrator['username'],
					'profile'=> System::baseUrl() . '/profile/' . $administrator['nickname'],
				];
			}
		}

		$visible_addons = Addon::getVisibleList();

		Config::load('feature_lock');
		$locked_features = [];
		$featureLock = Config::get('config', 'feature_lock');
		if (isset($featureLock)) {
			foreach ($featureLock as $k => $v) {
				if ($k === 'config_loaded') {
					continue;
				}

				$locked_features[$k] = intval($v);
			}
		}

{'fraction_non_alphanumeric': 0.2053221288515406, 'fraction_numerical': 0.0036414565826330533, 'mean_word_length': 4.787682333873581, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, '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': '2529965', 'n_tokens_mistral': 1383, 'n_tokens_neox': 1249, 'n_words': 212}