<commit_before><?php
class GoogleAuthenticationModule implements IAuthenticationModule
{
	private $siteid;
	private $regHeadersLoaded = false;
	private $adminHeaderShown = false;

	public function __construct($siteid)
	{
		$this->siteid = $siteid;
	}

	public function getID()
	{
		return "google";
	}

	public function getTitle()
	{
		return "Other accounts using Google Friend Connect";
	}

	public function getUserCredentials($user)
	{
		$db = UserConfig::getDB();

		$userid = $user->getID();

		if ($stmt = $db->prepare('SELECT google_id FROM '.UserConfig::$mysql_prefix.'googlefriendconnect WHERE user_id = ?'))
		{
			if (!$stmt->bind_param('i', $userid))
			{
				 throw new Exception("Can't bind parameter".$stmt->error);
			}
			if (!$stmt->execute())
			{
				throw new Exception("Can't execute statement: ".$stmt->error);
			}
			if (!$stmt->bind_result($google_id))
			{
				throw new Exception("Can't bind result: ".$stmt->error);
			}

			$google_ids = array();
			while ($stmt->fetch() === TRUE) {
				$google_ids[] = $google_id;
			}
			$stmt->close();

			if (count($google_ids) > 0)
			{
				$creds = '';

				if (!$this->adminHeaderShown) {
					$creds .= '
                <script src="http://www.google.com/jsapi"></script>
                <script src="http://www.google.com/friendconnect/script/friendconnect.js?key=notsupplied&v=0.8"></script>
                <script>
                google.setOnLoadCallback(function() {
                        google.friendconnect.container.loadOpenSocialApi({
                                site: \''.$this->siteid.'\',
                                onload: function(securityToken) {
                                        if (!window.timesloaded) {
                                                window.timesloaded = 1;
                                        } else {
                                                window.timesloaded++;
                                        }

                                        if (window.timesloaded > 1) {
                                                document.googleloginform.submit();
                                        }
                                }
                        });
                });
                </script>';
					$this->adminHeaderShown = true;
				}

				$first = true;
				foreach ($google_ids as $google_id) {
					if ($first) {
						$first = false;
					} else {
						$creds .= ', ';
					}
					$creds .= "<a href=\"#\" onclick=\"google.friendconnect.showMemberProfile('$google_id'); return false;\">$google_id</a>";
				}

				return $creds;
			}
		}
		else
		{
			throw new Exception("Can't prepare statement: ".$db->error);
		}

		return null;
	}

	/*
	 * retrieves aggregated registrations numbers 
	 */
	public function getDailyRegistrations()
	{
		$db = UserConfig::getDB();

		$dailyregs = array();

		if ($stmt = $db->prepare('SELECT CAST(regtime AS DATE) AS regdate, count(*) AS regs FROM '.UserConfig::$mysql_prefix.'users u LEFT JOIN '.UserConfig::$mysql_prefix.'googlefriendconnect g ON u.id = g.user_id WHERE g.google_id IS NOT NULL GROUP BY regtime'))
		{
			if (!$stmt->execute())
			{
				throw new Exception("Can't execute statement: ".$stmt->error);
			}
			if (!$stmt->bind_result($regdate, $regs))
			{
				throw new Exception("Can't bind result: ".$stmt->error);
			}
<commit_msg>Fixed Google Friend Connect query<commit_after><?php
class GoogleAuthenticationModule implements IAuthenticationModule
{
	private $siteid;
	private $regHeadersLoaded = false;
	private $adminHeaderShown = false;

	public function __construct($siteid)
	{
		$this->siteid = $siteid;
	}

	public function getID()
	{
		return "google";
	}

	public function getTitle()
	{
		return "Other accounts using Google Friend Connect";
	}

	public function getUserCredentials($user)
	{
		$db = UserConfig::getDB();

		$userid = $user->getID();

		if ($stmt = $db->prepare('SELECT google_id FROM '.UserConfig::$mysql_prefix.'googlefriendconnect WHERE user_id = ?'))
		{
			if (!$stmt->bind_param('i', $userid))
			{
				 throw new Exception("Can't bind parameter".$stmt->error);
			}
			if (!$stmt->execute())
			{
				throw new Exception("Can't execute statement: ".$stmt->error);
			}
			if (!$stmt->bind_result($google_id))
			{
				throw new Exception("Can't bind result: ".$stmt->error);
			}

			$google_ids = array();
			while ($stmt->fetch() === TRUE) {
				$google_ids[] = $google_id;
			}
			$stmt->close();

			if (count($google_ids) > 0)
			{
				$creds = '';

				if (!$this->adminHeaderShown) {
					$creds .= '
                <script src="http://www.google.com/jsapi"></script>
                <script src="http://www.google.com/friendconnect/script/friendconnect.js?key=notsupplied&v=0.8"></script>
                <script>
                google.setOnLoadCallback(function() {
                        google.friendconnect.container.loadOpenSocialApi({
                                site: \''.$this->siteid.'\',
                                onload: function(securityToken) {
                                        if (!window.timesloaded) {
                                                window.timesloaded = 1;
                                        } else {
                                                window.timesloaded++;
                                        }

                                        if (window.timesloaded > 1) {
                                                document.googleloginform.submit();
                                        }
                                }
                        });
                });
                </script>';
					$this->adminHeaderShown = true;
				}

				$first = true;
				foreach ($google_ids as $google_id) {
					if ($first) {
						$first = false;
					} else {
						$creds .= ', ';
					}
					$creds .= "<a href=\"#\" onclick=\"google.friendconnect.showMemberProfile('$google_id'); return false;\">$google_id</a>";
				}

				return $creds;
			}
		}
		else
		{
			throw new Exception("Can't prepare statement: ".$db->error);
		}

		return null;
	}

	/*
	 * retrieves aggregated registrations numbers 
	 */
	public function getDailyRegistrations()
	{
		$db = UserConfig::getDB();

		$dailyregs = array();

		if ($stmt = $db->prepare('SELECT regdate, count(*) AS reqs FROM (SELECT CAST(regtime AS DATE) AS regdate, id AS regs FROM '.UserConfig::$mysql_prefix.'users u LEFT JOIN '.UserConfig::$mysql_prefix.'googlefriendconnect g ON u.id = g.user_id WHERE g.google_id IS NOT NULL GROUP BY id) agg group by agg.regdate'))
		{
			if (!$stmt->execute())
			{
				throw new Exception("Can't execute statement: ".$stmt->error);
			}
			if (!$stmt->bind_result($regdate, $regs))
			{
				throw new Exception("Can't bind result: ".$stmt->error);
			}

{'fraction_non_alphanumeric': 0.14357311320754718, 'fraction_numerical': 0.001474056603773585, 'mean_word_length': 1.870135363790186, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 63, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 28, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6487915', 'n_tokens_mistral': 2228, 'n_tokens_neox': 1879, 'n_words': 408}