<commit_before><?php
/**
 * @copyright Copyright (C) 2010-2021, the Friendica project
 *
 * @license GNU AGPL version 3 or any later version
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 *
 */

namespace Friendica\Module;

use Friendica\BaseModule;
use Friendica\Content\Widget;
use Friendica\DI;
use Friendica\Core\Logger;
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
use Friendica\Core\Search;
use Friendica\Core\System;
use Friendica\Model\Contact;
use Friendica\Model\Profile;
use Friendica\Model\User;
use Friendica\Network\Probe;

/**
 * Remotely follow the account on this system by the provided account
 */
class RemoteFollow extends BaseModule
{
	static $owner;

	public static function init(array $parameters = [])
	{
		self::$owner = User::getOwnerDataByNick($parameters['profile']);

		DI::page()['aside'] = Widget\VCard::getHTML(self::$owner);
	}

	public static function post(array $parameters = [])
	{
		if (!empty($_POST['cancel']) || empty($_POST['dfrn_url'])) {
			DI::baseUrl()->redirect();
		}
	
		if (empty(self::$owner)) {
			notice(DI::l10n()->t('Profile unavailable.'));
			return;
		}
		
		$url = Probe::cleanURI($_POST['dfrn_url']);
		if (!strlen($url)) {
			notice(DI::l10n()->t("Invalid locator"));
			return;
		}

		// Detect the network, make sure the provided URL is valid
		$data = Contact::getByURL($url);
		if (!$data) {
			notice(DI::l10n()->t("The provided profile link doesn't seem to be valid"));<commit_msg>Abort early if owner isn't found in Module\RemoteFollow<commit_after><?php
/**
 * @copyright Copyright (C) 2010-2021, the Friendica project
 *
 * @license GNU AGPL version 3 or any later version
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 *
 */

namespace Friendica\Module;

use Friendica\BaseModule;
use Friendica\Content\Widget;
use Friendica\DI;
use Friendica\Core\Logger;
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
use Friendica\Core\Search;
use Friendica\Core\System;
use Friendica\Model\Contact;
use Friendica\Model\Profile;
use Friendica\Model\User;
use Friendica\Network\HTTPException;
use Friendica\Network\Probe;

/**
 * Remotely follow the account on this system by the provided account
 */
class RemoteFollow extends BaseModule
{
	static $owner;

	public static function init(array $parameters = [])
	{
		self::$owner = User::getOwnerDataByNick($parameters['profile']);
		if (!self::$owner) {
			throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
		}

		DI::page()['aside'] = Widget\VCard::getHTML(self::$owner);
	}

	public static function post(array $parameters = [])
	{
		if (!empty($_POST['cancel']) || empty($_POST['dfrn_url'])) {
			DI::baseUrl()->redirect();
		}
	
		if (empty(self::$owner)) {
			notice(DI::l10n()->t('Profile unavailable.'));
			return;
		}
		
		$url = Probe::cleanURI($_POST['dfrn_url']);
		if (!strlen($url)) {
			notice(DI::l10n()->t("Invalid locator"));
			return;
		}

		// Detect the network, make sure the provided URL is valid
		$data = Contact::getByURL($url);
		if (!$data) {
			notice(DI::l10n()->t("The provided profile link doesn't seem to be valid"));
{'fraction_non_alphanumeric': 0.1285583103764922, 'fraction_numerical': 0.007805325987144169, 'mean_word_length': 4.405707196029777, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 14, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '5777914', 'n_tokens_mistral': 1372, 'n_tokens_neox': 1284, 'n_words': 445}