Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Issues (412)

src/tools/irc/channel.php (1 issue)

Severity
1
<?php declare(strict_types=1);
2
3
use Smr\Database;
4
5
/**
6
 * @param resource $fp
7
 */
8
function channel_join($fp, string $rdata): bool {
9
10
	if (preg_match('/^:(.*)!(.*)@(.*)\sJOIN\s:(.*)\s$/i', $rdata, $msg)) {
11
12
		$nick = $msg[1];
13
		$user = $msg[2];
14
		$host = $msg[3];
15
		$channel = $msg[4];
16
17
		echo_r('[JOIN] ' . $nick . '!' . $user . '@' . $host . ' joined ' . $channel);
18
19
		$db = Database::getInstance();
20
21
		// check if we have seen this user before
22
		$dbResult = $db->read('SELECT * FROM irc_seen WHERE nick = ' . $db->escapeString($nick) . ' AND channel = ' . $db->escapeString($channel));
23
24
		if ($dbResult->hasRecord()) {
25
			$dbRecord = $dbResult->record();
26
			// existing nick?
27
			$seen_id = $dbRecord->getInt('seen_id');
28
29
			$seen_count = $dbRecord->getInt('seen_count');
30
			$seen_by = $dbRecord->getNullableString('seen_by');
31
32
			if ($seen_count > 1) {
33
				fwrite($fp, 'PRIVMSG ' . $channel . ' :Welcome back ' . $nick . '. While being away ' . $seen_count . ' players were looking for you, the last one being ' . $seen_by . EOL);
34
			} elseif ($seen_count > 0) {
35
				fwrite($fp, 'PRIVMSG ' . $channel . ' :Welcome back ' . $nick . '. While being away ' . $seen_by . ' was looking for you.' . EOL);
36
			}
37
38
			$db->write('UPDATE irc_seen
39
						SET signed_on = ' . $db->escapeNumber(time()) . ',
40
							signed_off = 0,
41
							user = ' . $db->escapeString($user) . ',
42
							host = ' . $db->escapeString($host) . ',
43
							seen_count = 0,
44
							seen_by = NULL,
45
							registered = NULL
46
						WHERE seen_id = ' . $db->escapeNumber($seen_id));
47
48
		} else {
49
			// new nick?
50
			$db->insert('irc_seen', [
51
				'nick' => $db->escapeString($nick),
52
				'user' => $db->escapeString($user),
53
				'host' => $db->escapeString($host),
54
				'channel' => $db->escapeString($channel),
55
				'signed_on' => $db->escapeNumber(time()),
56
			]);
57
58
			if ($nick != IRC_BOT_NICK) {
59
				fwrite($fp, 'PRIVMSG ' . $channel . ' :Welcome, ' . $nick . '! Most players are using Discord (' . DISCORD_URL . ') instead of IRC, but the two platforms are linked by discordbot. Anything you say here will be relayed to the Discord channel and vice versa.' . EOL);
60
			}
61
		}
62
63
		// check if player joined alliance chat
64
		channel_op_notification($fp, $rdata, $nick, $channel);
65
66
		return true;
67
	}
68
69
	return false;
70
}
71
72
/**
73
 * @param resource $fp
74
 */
75
function channel_part($fp, string $rdata): bool {
0 ignored issues
show
The parameter $fp is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

75
function channel_part(/** @scrutinizer ignore-unused */ $fp, string $rdata): bool {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
76
77
	// :[email protected] PART #smr-irc :
78
	// :[email protected] PART #smr-irc
79
	if (preg_match('/^:(.*)!(.*)@(.*)\sPART\s(.*?)\s/i', $rdata, $msg)) {
80
81
		$nick = $msg[1];
82
		$user = $msg[2];
83
		$host = $msg[3];
84
		$channel = $msg[4];
85
86
		echo_r('[PART] ' . $nick . '!' . $user . '@' . $host . ' ' . $channel);
87
88
		// database object
89
		$db = Database::getInstance();
90
91
		$dbResult = $db->read('SELECT * FROM irc_seen WHERE nick = ' . $db->escapeString($nick) . ' AND channel = ' . $db->escapeString($channel));
92
93
		// exiting nick?
94
		if ($dbResult->hasRecord()) {
95
96
			$seen_id = $dbResult->record()->getInt('seen_id');
97
98
			$db->write('UPDATE irc_seen SET signed_off = ' . time() . ' WHERE seen_id = ' . $seen_id);
99
100
		} else {
101
			// we don't know this one, but who cares? he just left anyway...
102
		}
103
104
		return true;
105
	}
106
107
	return false;
108
}
109