<commit_before><?php
if(!defined("IN_MYBB"))
{
    die("This file cannot be accessed directly.");
} 

$plugins->add_hook('member_profile_end', 'showrefer');
$plugins->add_hook("member_do_register_end", "showrefer_send_pm");

// The information that shows up on the plugin manager
function showrefer_info()
{
	return array(
		"name"		=> "Referral in Profile",
		"description"	=> "This plugin displays the user's referrals in their profiles.",
		"website"	=> "http://www.leefish.nl",
		"author"	=> "LeeFish based on work by <NAME>",
		"authorsite"	=> "http://www.leefish.nl",
		"version"	=> "1.1",
		'compatibility' => "18"
	);
}

// This function is called to establish whether the plugin is installed or not
function showrefer_is_installed()
{
	global $db;
	
	$query = $db->simple_select("templates", "`title`", "`title` = 'member_profile_showrefer'");
	$g = $db->fetch_array($query);
	if($g)
	{
		return true;
	}
	return false;
}

function showrefer_install() {
	global $db;

	$showrefer_template = array(
		"title"		=> 'member_profile_showrefer',
		"template"	=> "<tr>
	<td class=\"trow1\ \"valign = top\"><strong>Referrals ({\$showrefer_count})</strong></td>
	<td class=\"trow1\">{\$showrefer_referrals}</td>
</tr>",
		"sid"		=> -1,
		"version"	=> 120,
		"status"	=> '',
		"dateline"	=> 1134703642,
	);
	//Create Referrals in Profiles template
	$db->insert_query('templates', $showrefer_template);
}

// This function runs when the plugin is activated.
function showrefer_activate()
{
	// Insert code into profile template
	require_once MYBB_ROOT."/inc/adminfunctions_templates.php";
	find_replace_templatesets("member_profile", '#{\$reputation}#', "{\$reputation}\n{\$showrefer}\n");
}

// This function runs when the plugin is deactivated.
function showrefer_deactivate()
{
	// Remove code from template
	require_once MYBB_ROOT."/inc/adminfunctions_templates.php";
	find_replace_templatesets("member_profile", '#(\n?){\$showrefer}(\n?)#', '', 0);
}

// This function runs when the plugin is deactivated.
function showrefer_uninstall()
{
    global $db;

	// Remove code from template
	require_once MYBB_ROOT."/inc/adminfunctions_templates.php";
	find_replace_templatesets("member_profile", '#(\n?){\$showrefer}(\n?)#', '', 0);
	
	//Delete Referrals in Profiles template
	$db->delete_query("templates", "`title` = 'member_profile_showrefer'");
	
	//Rebuild settings.php
	rebuild_settings();
}
<commit_msg>Comments updates and template cache<commit_after><?php
if(!defined("IN_MYBB"))
{
    die("This file cannot be accessed directly.");
} 
// Credits: DennisTT for PM function, Rakes for query optimisation and name format, JeffChan for the 1.4 plugin 
// Neat trick for caching our custom template(s)
if(my_strpos($_SERVER['PHP_SELF'], 'member.php'))
{
	global $templatelist;
	if(isset($templatelist))
	{
		$templatelist .= ',';
	}
	$templatelist .= 'member_profile_showrefer';
}

$plugins->add_hook('member_profile_end', 'showrefer');
$plugins->add_hook("member_do_register_end", "showrefer_send_pm");

// The information that shows up on the plugin manager
function showrefer_info()
{
	return array(
		"name"		=> "Referral in Profile",
		"description"	=> "This plugin displays the user's referrals in their profiles.",
		"website"	=> "http://www.leefish.nl",
		"author"	=> "LeeFish",
		"authorsite"	=> "http://www.leefish.nl",
		"version"	=> "1.1",
		'compatibility' => "18",
		"codename" => "leefish_showrefer"
	);
}

// This function is called to establish whether the plugin is installed or not
function showrefer_is_installed()
{
	global $db;
	
	$query = $db->simple_select("templates", "`title`", "`title` = 'member_profile_showrefer'");
	$g = $db->fetch_array($query);
	if($g)
	{
		return true;
	}
	return false;
}

function showrefer_install() {
	global $db;

	$showrefer_template = array(
		"title"		=> 'member_profile_showrefer',
		"template"	=> "<tr>
	<td class=\"trow1\ \"valign = top\"><strong>Referrals ({\$showrefer_count})</strong></td>
	<td class=\"trow1\">{\$showrefer_referrals}</td>
</tr>",
		"sid"		=> -1,
		"version"	=> 120,
		"status"	=> '',
		"dateline"	=> 1134703642,
	);
	//Create Referrals in Profiles template
	$db->insert_query('templates', $showrefer_template);
}

// This function runs when the plugin is activated.
function showrefer_activate()
{
	// Insert code into profile template
	require_once MYBB_ROOT."/inc/adminfunctions_templates.php";
	find_replace_templatesets("member_profile", '#{\$reputation}#', "{\$reputation}\n{\$showrefer}\n");
}

// This function runs when the plugin is deactivated.
function showrefer_deactivate()
{
	// Remove code from template
	require_once MYBB_ROOT."/inc/adminfunctions_templates.php";
	find_replace_templatesets("member_profile", '#(\n?){\$showrefer}(\n?)#', '', 0);
}

// This function runs when the plugin is uninstalled.
function showrefer_uninstall()
{
    global $db;

	//Delete Referrals in Profiles template
	$db->delete_query("templates", "`title` = 'member_profile_showrefer'");
	
	//Rebuild settings.php
	rebuild_settings();
}

{'fraction_non_alphanumeric': 0.16995417413827454, 'fraction_numerical': 0.008965929468021518, 'mean_word_length': 5.040914560770156, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 59, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '87331', 'n_tokens_mistral': 1803, 'n_tokens_neox': 1729, 'n_words': 398}